I am using jQuery.ajax function to make an ajax call to a page method in asp.net. I specifically set the content-type to application/json; charset=utf-8. When I looked at the response in the firebug it says the content-type is html.
The following is the code to my ajax call:
$.ajax({
async: asyncVal,
type: "POST",
url: url + '/' + webMethod,
data: dataPackage,
contentType: "application/json; charset=UTF-8",
dataType: "json",
error: errorFunction,
success: successFunction
});
You request a certain content type, but if your script does not handle this request by setting the response headers accordingly, you let IIS decide what to return. Just force the header to the right value.
I am missing the "ScriptModule" tag in the web.config on the server. After I added that tag everything worked fine.
Thanks for your help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With