Similar to this question. pass jquery json into asp.net . Follow the link, it might be useful for you.
How can I do to recieve json from jquery's ajax request in asp.net?
-
03-10-2022 - |
Frage
$.ajax({
url : "Handler1.ashx",
type : "GET",
cache : false,
data : {
type : "refresh",
point: [x:1,y:2]
});
The "type" can be "POST". In "Handler1.ashx", I have "HttpContext" object, so how can I get the json from the "HttpContext" object?
I found it is misunderstanding,I means:
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
// How can I get json here?
}
Lösung
Andere Tipps
Use success callback to get your json data
Following code may help you..
$.ajax({
url : "Handler1.ashx",
type : "GET",
cache : false,
data : {
type : "refresh",
point: [x:1,y:2]
},
success: function(res){
//do your code.
//here res is your json which you return from Handler1.ashx
console.log(res);
}
});
You need to use the success
callback to capture the data returned from the request, as shown below:
$.ajax({
url : "Handler1.ashx",
type : "GET",
cache : false,
data : {
type : "refresh",
point: [x:1,y:2]
},
success: function(responsedata){
alert(responsedata); // <-- there's your data
}
});
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow