First time using jquery (using the out of the box 1.4.4 in MVC3 even though its dated).
I am trying to update some elements on the screen as follows,
$(document).ready(function () {
$.ajax({
url: '<snip />',
dataType: 'json',
success: function (data, textStatus, jqXHR) {
// <snip />
},
error: function (jqXHR, textStatus, errorThrown) {
// <snip />
}
});
});
This always calls the error function, even though in the jqXHR object I can clearly see the text response
"{
"DBHealth": "Grey",
"FSHealth": "Grey",
"WSHealth": "Grey"
}"
Full HTTP server response is (courtesy of WireShark),
HTTP/1.1 200 OK
Cache-Control: private, s-maxage=0
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 3.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Persistent-Auth: true
Date: Thu, 03 May 2012 14:11:23 GMT
Content-Length: 72
{
"DBHealth": "Grey",
"FSHealth": "Grey",
"WSHealth": "Grey"
}
textStatus is error rather than parsererror, so I assume the problem is not my JSON.
errorThrown is null unsurprisingly as its.
Obvious question is, why is it erroring?
Visual Studio was being silly. Restarted the debug session and it succeeded just fine. Didn’t change anything in the javascript or server side Controller.