views:

50

answers:

0

I have the following 2 jQuery Ajax calls. The first is a call to a Asp.Net Json Webservice and always works. The second is a call to a ASP.Net MVC action that return an json result. This call always fails with Status=12031 the first time the page is loaded. The responseText is empty. After a refresh de second call usually works fine.

jQuery(document).ready(function () {

jQuery.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: "/Services/MenuService.svc/Get",
    dataType: "json",
    data: '{}',
    success: function (data) {
        jQuery.map(data.d, function (item) {
            jQuery("#menu").append('<li><a href="/Menu/' + item.Link + '">' + item.Link + '</a></li>') 
        });
    },
    error: function (XMLHttpRequest, textStatus, errorThrown) {
        if (XMLHttpRequest.responseText != '') {
            alert(XMLHttpRequest.responseText);
        }
    }
});

jQuery.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: "/Menu/Get",
    dataType: "json",
    data: '{}',
    success: function (data) {
        jQuery.map(data, function (item) {
            jQuery("#menu").append('<li><a href="/Menu/' + item.Link + '">' + item.Link + '</a></li>')
        });
    },
    error: function (XMLHttpRequest, textStatus, errorThrown) {
        if (XMLHttpRequest.responseText != '') {
            alert(XMLHttpRequest.responseText);
        }
    }
});

});

Does anyone knows why I get the 12031 Status on the second call?