jquery ajax call return JSON parsing error jquery ajax call return JSON parsing error ajax ajax

jquery ajax call return JSON parsing error


Here, "application/json" is not a valid value for the dataType property.I changed it to "json" in my project and the same problem was solved.

Please check details here (comment #7): http://bugs.jquery.com/ticket/8216


Try adding the MIME type in your server-side code:

Response.ContentType = "application/json";


With WCF 4.0, you can add an attribute called automaticFormatSelectionEnabled which allows the service to look at the Accept header in the HTTP request to determine what format to return. As long as what you are returning is serializable, WCF will handle the correct serialization for you. In your jQuery ajax call, the Accept header is added by including accepts: {json: "application/json"}.