jquery - Firefox 中未发送 Ajax 请求,错误未知

标签 jquery ajax firefox

在 Firefox 27.0.1、Fedora 20、jQuery 1.11.0 中执行此 GET 同步 ajax 请求时:

$.ajax(ajaxParam).then(
    function (r) {
        html = r.html;
    },
    function (jqXHR) {
        console.log(JSON.stringify([jqXHR, $.ajaxSettings, ajaxParam], null, 4));
    }
);

它可以在适用于 Linux 的 Chrome 33.0.1750.146 中运行,但在 Firefox 中,不会向服务器发送请求,并且会出错:

[
    {
        "readyState": 0,
        "status": 0,
        "statusText": "[Exception... \"<no message>\"  nsresult: \"0x805e0006 (<unknown>)\"  location: \"JS frame :: http://example.com/static/jquery-1.11.0.min.js :: .send :: line 4\"  data: no]"
    },
    {
        "url": "http://example.com/pt/BR",
        "type": "GET",
        "isLocal": false,
        "global": true,
        "processData": true,
        "async": true,
        "contentType": "application/x-www-form-urlencoded; charset=UTF-8",
        "accepts": {
            "*": "*/*",
            "text": "text/plain",
            "html": "text/html",
            "xml": "application/xml, text/xml",
            "json": "application/json, text/javascript",
            "script": "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
        },
        "contents": {
            "xml": {},
            "html": {},
            "json": {},
            "script": {}
        },
        "responseFields": {
            "xml": "responseXML",
            "text": "responseText",
            "json": "responseJSON"
        },
        "converters": {
            "text html": true
        },
        "flatOptions": {
            "url": true,
            "context": true
        },
        "jsonp": "callback",
        "cache": false,
        "traditional": true,
        "dataType": "json"
    },
    {
        "url": "/advert/pt/BR",
        "data": {
            "realty_id": "2"
        },
        "async": false,
        "type": "GET"
    }
]

nserror 0x805e0006 is NS_ERROR_CONTENT_BLOCKED

<小时/>

回答epascarello

ajax 调用在此函数内

function popupOpen(params, page, html) {
    loadScripts();
    var ajaxParam = {
            url: '/' + page.url + '/' + $('#lang_code').val() + '/' + $('#terr_code').val(),
            data: params,
            async: false,
            type: page.method,
            traditional: false
        },
        realtyId = params.realty_id;
    if (!html) {
        $.ajax(ajaxParam).then(
            function (r) {
                html = r.html;
            },
            function (jqXHR) {
                console.log(jqXHR, $.ajaxSettings, ajaxParam);
            }
        );
    }

并且 popupOpen 由 Google map 中的点击监听器调用

gm.event.addListener(marker[realtyId], 'click', function () {
    infoWindow[realtyId].open(map, marker[realtyId]);
    popupOpen({ realty_id: realtyId }, realtyId === 0 ? pageO.modify : pageO.advert);
});

最佳答案

由于目标网址有广告世界,Adblock Plus 会阻止它。很好,在投入生产之前,这件事就发生在我身上。

关于jquery - Firefox 中未发送 Ajax 请求,错误未知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22304429/

相关文章:

javascript - 如何使用默认值加载可能未定义的模板变量?

javascript - knockout 绑定(bind)处理程序未定义错误

javascript - 通过 jquery 的 wordpress 自定义字段值

jquery - 始终对 jQuery Ajax 的发布数据调用 JSON.stringify

jquery - 将 AJAX 结果附加到列表

javascript - Firefox for Android 输入文件 onchange 在使用相机时不会触发

javascript - 如何将 AJAX 返回的字符串转换为对象的 javascript 数组

javascript - 带有 Jsf 1.1 实现的 Ajax

firefox - 已删除的 Firefox token 仍可通过 Mozilla 推送服务器推送

html - 在 firefox/IE 上显示 iframe 的问题