Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC 4 $Ajax JSON Request returns status 0, statusText: "error"
    primarykey
    data
    text
    <p>I am trying update a value on my page every 5 seconds using jQuery $.ajax, this code used to work fine, but after deployment to production server it appears to be randomly failing. On some pages it will work, and on others if fails with the error: status 0, statusText: "error".</p> <p>Can anyone spot any errors misnomers in the code / markup?</p> <p>I use this to call my method every 5 seconds:</p> <pre><code>setInterval(function () { updateMessages(); }, 5000); </code></pre> <p>updateMessages looks like this:</p> <pre><code>function updateMessages() { $.ajax({ beforeSend: function () { }, complete: function () { }, type: "GET", url: '@Url.Action("GetUnreadMessagesJson", "Message", new { Area = "" })', contentType: "application/json; charset=utf-8", dataType: "json", success: function (result) { var newUnreadMessages = result.UnreadMsgCount; }, error: function (rsult) { console.log(rsult); } }); } </code></pre> <p>My server code (Action) inside the MVC Controller looks like this:</p> <pre><code>public ActionResult GetUnreadMessagesJson() { int unreadMessages = 0; try { unreadMessages = messageService.GetUnreadMessageCount(WebSecurity.CurrentUserId); } catch (Exception) { throw; } return Json(new { UnreadMsgCount = unreadMessages //,UnreadMessages = unreadMessages }, JsonRequestBehavior.AllowGet); } </code></pre> <p>When I use Fiddler2 to analyse the request on my local machine I see this in the response:</p> <blockquote> <p>HTTP/1.1 200 OK Cache-Control: private Content-Type: application/json; charset=utf-8 Server: Microsoft-IIS/7.5 X-AspNetMvc-Version: 4.0 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Date: Wed, 31 Jul 2013 17:38:50 GMT Content-Length: 20</p> </blockquote> <p>{"UnreadMsgCount":3}</p> <p>Which looks good and is what I expect, but I never see this request when the site is live. Fiddler2 never shows any outgoing Ajax request, Google Chrome's Console shows:</p> <blockquote> <p>Object {readyState: 0, getResponseHeader: function, getAllResponseHeaders: function, setRequestHeader: function, overrideMimeType: function…}</p> </blockquote> <p>Which has status:0 and statusText: "error" inside. Nothing more.</p> <p>How on earth do I go about investigating this issue if there is nothing wrong with my code? Has anyone seen this before?</p> <p><strong>EDIT</strong></p> <p>After testing this issue with several browsers including IE, Firefox and Safari it appears that the issue is only limited to Google Chrome. I have submitted a bug report <a href="https://code.google.com/p/chromium/issues/detail?id=266483" rel="nofollow">here</a> and will update this post with any response I get.</p> <p>Thanks,</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload