i’m using asp.net mvc2 with jquery 1.5.2. what i pretend is to make client-side call to a specific method in my controller that returns a json data.
Actually, my client-side call to server is working, but the problem is that jquery doesn’t recognize the returned json.
I cannot understand what i’m doing wrong!, can some one helpme with this?
Controller method:
<HttpPost()> _
Function DoStuff(ByVal id As Integer) As JsonResult
Dim retval As JsonResult = Nothing
retval = Json(New xpto With {.P1 = "P1Value"})
Return retval
End Function
JQuery Ajax call:
$.ajax({
url: "/DoStuff/5",
type: "POST",
dataType: "json",
async: false,
success: function(data, textStatus, jqXHR) {
alert(textStatus);
},
error: function(jqXHR, textStatus, errorThrown) {
alert(textStatus);
}
});
Values when Handles Error method:
errorThrown: jQuery1520029581770420782693_1303980789842 was not called
textStatus: parsererror
jqXHR.responseText = "{"P1":"P1Value"}"
The problem was not in the on that code, that is working fine, the problem is generated by the Sctipt tag order on the markup (validate)
WRONG:
RIGHT: