Alex Rivera | Logout

ASP.NET - Passing JSON from jQuery to ASHX

Asked 2010-06-01T09:35:18.330
44

I'm trying to pass JSON from jQuery to a .ASHX file. Example of the jQuery below:

$.ajax({
      type: "POST",
      url: "/test.ashx",
      data: "{'file':'dave', 'type':'ward'}",
      contentType: "application/json; charset=utf-8",
      dataType: "json",      
    });

How do I retrieve the JSON data in my .ASHX file? I have the method:

public void ProcessRequest(HttpContext context)

but I can't find the JSON values in the request.

Edit
Report

1 Answer

-1

if using $.ajax and using .ashx to get querystring ,dont set datatype

$.ajax({ 
    type: "POST", 
    url: "/test.ashx", 
    data: {'file':'dave', 'type':'ward'}, 
    **//contentType: "application/json; charset=utf-8",   
    //dataType: "json"**    
}); 

i get it work!

answered 2010-08-05T10:54:26.040

Your Answer