I got the following working after spinning my head around a thousand times and then referring parserrror SyntaxError: Unexpected token < - Load Partial View using jQuery Ajax in ASP.NET MVC 4
I have the following code in my ASP.Net 2.0
project. It works – but to get it to work, I am using dataType: "html"
. When I use JSON as datatype I get a parse error: Unexpected token <
How can we make it work with JSON
?
Note: Though I am using IE8, some of my users are still using IE6. So I need a solution that works in IE6.
jQuery Ajax
$.ajax({
type: "GET",
url: "admPlantParametersViewEdit.aspx/GetResult",
contentType: "application/json; charset=utf-8",
dataType: "html",
success: function(msg)
{
alert("Hi");
},
error: errorFunction
});
VB.Net
<WebMethod()> _
Public Shared Function GetResult() As String
Return "hello"
End Function
Request and Response Headers
References
- Differences between contentType and dataType in jQuery ajax function
- What is content-type and datatype in an AJAX request?
- How to return JSON from a 2.0 asmx web service
- ASP.NET AJAX PageMethods call load whole page for .NET 4.5 IIS 7.5
- Support cross-domain requests (specifically multiple methods in WebInvoke) in Rest WCF
- jQuery $.ajax(), $.post sending "OPTIONS" as REQUEST_METHOD in Firefox
- Cannot set content-type to 'application/json' in jQuery.ajax