Question

I have implemented the following $.Post Jquery function in my asp.net page MAIN Page.aspx the

$.post({ url: "MAIN Page.aspx",
         data: { "Status":ddl },
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",

                });

where ddl is my data to be posted ...i have placed this $.post in the document.ready() and i tried accessing the posted value in the code behind as

var status= Request.Form.Get["Status"]...

but when i run the code the value of the status is null..

please help and guide if i am correct in my implementation of the logic

Was it helpful?

Solution

Try like this:

$.post('MAIN Page.aspx', { status: ddl }, function(result) {
    alert('success');
});

and on your server:

var status= Request.Form["Status"];

Also you haven't shown what this ddl javascript variable is and how you assigned it a value but make sure that it is not a complex object but it contains some simple type.

Alternatively if you want to use the $.ajax method:

$.ajax({
    url: 'MAIN Page.aspx',
    type: 'POST',
    data: { status: ddl },
    success: function(result) {
        alert('result');
    }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top