I currently have some jquery that is POSTing data onto one of my web pages.
Right now I'm just trying to get it to post some JSON to test it out, but I can't figure out have to actually get the data in my back-end once it's posted.
I've always used Request.Params to get posted data, but it doesn't seem to be working this time.
This is the code I'm using to do the post:
// This data is just for testing purposes, doesn't actually do anything
var person = {
name: "Bob",
address: "123 Main St.",
phone: "555-5555"
}
var jqxhr = $.ajax({
type: "POST",
url: "/example/mypage.aspx",
contentType: 'application/json; charset=utf-8',
dataType: "json",
timeout: 0,
success: function () {
alert("Success");
},
error: function (xhr, status, error) {
alert(error);
},
data: person
});
The post is definitely successful though, as I can see it using Fiddler, plus when I check Request.ContentLength it returns the right number of bytes that was posted.
But I can't find the actual data anywhere. Any ideas on what I'm doing wrong?
Thanks in advance.
datais your data - had the same issue a few days ago: stackoverflow.com/questions/29132493/…dataobject is just what I used to post the json data.datavariable name, not sure if it's messing with things. In any event, unsure how to accomplish what you are looking for - however, take a look here: msdn.microsoft.com/en-us/library/aa530946.aspx