Fetching JSON data in the code-behind fileExplanation on how to retrieve

<script type="text/javascript" language="javascript">
        $(document).ready(function () {

            var LastRecID = 1;
            $(window).scroll(function () {
                if ($(window).scrollTop() == $(document).height() - $(window).height()) {
                    var ImpData = document.getElementById('<%= hdnLanguage.ClientID %>').value;
                    if (LastRecID <= 1)
                        sendData();
                    LastRecID++;
                }
            });

            function sendData() {

                $.ajax(
                 {
                     type: "POST",
                     url: "try.aspx/GetData",
                     data: ImpData ,
                     contentType: "application/json; charset=utf-8",
                     dataType: "json",
                     async: "true",
                     cache: "true",

                     success: function (msg) {
                         $("#myDiv").append(msg.d);
                     },

                     Error: function (x, e) {
                         alert("err");
                     }

                 });

            }

        });


    </script>

I am utilizing a hidden field with the same value as ImpData is set to hdnLanguage.

 var ImpData = document.getElementById('<%= hdnLanguage.ClientID %>').value;

The data is being sent using JSON:

data: ImpData 

I am seeking assistance on how to access this data (ImpData) in the code behind (in a static web service). Thank you for your help.

Answer №1

When you pass the data, it gets converted into the parameters for the GetData. For example, if you provide the data in this format:

data: { param1: ImpData }

Make sure your GetData method includes at least the param1 parameter like this:

public static void GetData(string param1)

Answer №2

I have discovered the solution

JSON:

information: "{'Parameter': '" + Parameter + "'}"

Backend Code:

public static string RetrieveData(string Parameter)
{

....

}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How to showcase a specific row in a React Native ListView for displaying highscores in a game

Currently, I am working on programming a Highscore Screen for a Quiz Game that utilizes a ListView to display all the players along with their scores. My main goal is to emphasize my own points, since the ListView only shows player IDs and points without a ...

Methods for altering the color of a div using addEventListener

Why doesn't the color change when I click on the div with the class "round"? Also, how can I implement a color change onclick? var round = document.querySelector(".round"); round.addEventListener("click", function() { round.style.backgroundCol ...

Parsing a JSON object in JavaScript: A step-by-step guide

Looking for assistance on how to parse the JSON object below: { "info": [ { "systemIp": "192.168.1.1", "status": "done 956" }, { "systemIp": "192.153.1.1", "status": "done" } ] } Does anyone have a solution using Javascript or jQuery? The desired output ...

Unlimited scrolling gallery with multiple rows

I am looking for a way to create a multi-row infinite loop scrolling gallery using html, css, and javascript. Can anyone help me with this? ...

Is there a way to prevent the entire row from being selected when a radio button is clicked in an md-data

Can anyone assist me with an issue I am having with my data table? When I select a radio button, the entire table row is getting selected instead of just the radio button. Below is the code snippet: https://i.sstatic.net/dicwF.png My Expectation: When c ...

What could be causing my header component to rerender even when there are no new props being received?

https://codesandbox.io/s/crimson-field-83hx6 In my project, I have a Header component that simply displays a fixed text and includes a console.log statement: const Header = props => { console.log("header render"); return ( <header> ...

Passing values from a Laravel controller to a Vue component as a prop

At the moment, I have a Laravel route that directs to the index function of my controller with an ID passed, where I then return the ID in a view. public function index($id) { return view('progress') ->with('identifier', ...

When attempting to send emails, SendGrid encounters an error and fails to provide an error code

Earlier today, I successfully sent out a series of emails using SendGrid. It was quite a large number of emails, as I needed to create multiple user accounts with attached email addresses. Thankfully, everything went smoothly and all the emails were delive ...

Real-time functionality in React component and Apollo Client is not functioning as expected

I am struggling to develop a user system as it is not working in real-time, causing confusion for me. To illustrate my problem and code, I have set up a sample Sandbox. Please note that this example does not include any validation features and is solely f ...

Serialization of JAVA object mapper using mixin and modified getter functions

When using the Jackson Object Mapper and MixIn class to map an object into JSON, I encountered a situation where I needed to customize the output of a getter method without direct access to the code. For example, consider the following object: public clas ...

A guide on navigating through nested JSON objects with the help of async.js

Having recently transitioned from a Python background to nodeJS/Javascript's asynchronous nature, I am exploring how to traverse a nested JSON object and extract its values using async.js. In my quest for answers, I stumbled upon this helpful snippet ...

javascript When the page is equal to X, logical operators do not perform their function

When navigating to pageAge or pageMore, I want the if statement not to execute. It functions properly on pageAge by not running the script, but on pageMore it does. I am unsure which operator to use in this scenario. Placing pageMore before the || works ...

Using C# to serialize an array of objects to JSON may encounter issues

Hi there, I'm currently facing an issue with serializing an array of objects in C# to JSON. This is the code I am using: friendlyNotification[] notifications = ns.friendlyNotifications.ToArray(); string json = JsonConvert.SerializeOb ...

Issue with radio button: checked property remains unchanged

There seems to be an issue with a div element where a table is being appended with input elements of type radio. The checked property does not change when clicked. What could be causing this problem? <input type="radio" id="radHalf0" name="grp0" class= ...

Designing a button component with text

Exploring My Demo Page, I am attempting to design a button that will serve as a closure mechanism for modals. The code snippet I experimented with is as follows: x=document.createElement('button'); x.className='superclose'; Referencin ...

Locate the div element containing specific text and remove the text from the

Is there a way to locate a div that contains specific text and remove only that specific text from the div? For instance: <div> DeleteText <span>Something text</span> <div>Something span inner text </div> </div> I am l ...

Avoid Sequelize automatically appending 'Id' to column names caused by association configurations

When using Sequelize to query data, I've noticed that 'Id' is automatically added to the end of my column name. How can I prevent this from happening? Below is an example of the entity data Model for Sequelize that I have created: function ...

What steps should I follow to include a JSON Request file in my project?

I've been working on integrating the Google Translation API into my project and came across some helpful information in the documentation here. According to the instructions, I need to Follow these steps to create a JSON request file with specific ...

Decipher a complicated JSON object

Encountered an issue at work involving parsing a JSON file to populate a table. Struggling with extracting specific data from the JSON. Here's a snippet of the code: NSData *jsonData = [NSData dataWithContentsOfURL:url]; NSDictionary* json = [NSJSONS ...

javascript event-driven class

I'm facing a challenge in creating a class with chained functions, and I could really use some assistance. Currently, this is what I have: robin = new batman("myiv"); var batman = (function() { var me = this; function batman(id){ me._ ...