سؤال

$.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?
}
هل كانت مفيدة؟

المحلول

Similar to this question. pass jquery json into asp.net . Follow the link, it might be useful for you.

نصائح أخرى

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

     }
 });
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top