0

ajax 调用创建问题。它在浏览器中运行良好,但通过 ajax 不会被调用。网址在这里http://testbed2.baileyprofile.com/dd-api.php?test=1

当我在 Firefox 检查元素控制台中检查它时。它发送请求并在大约 900 毫秒或 mroe 后给出消息 200 Ok 并且 url 颜色变为红色。它根本不产生任何响应。

请任何提示它可能有什么问题。我的代码如下

 jQuery.post(ajaxurl, {action: 'test' }, function(response) {
        if (response!= '') {
             jQuery('#test-result').html("Restule is generated successfully, copy of result has been sent to your inbox").fadeOut(10000);
             document.getElementById("txtFeedback").value= response;
            //console.log(response.data);
            //alert('POST title: ' + response.data.post_title);
        } else {
            // something didn't go well
            console.log(response.status);
        }
    });
4

2 回答 2

1

更新:

我有 a.com 并向 b.com 发送请求。它应该有什么问题吗?

你违反了Same origin policy,你不能从域a.com到ajaxb.com

于 2012-06-01T13:03:01.430 回答
0

数据参数应该在''之内。尝试一下,它应该可以工作

jQuery.post(ajaxurl, {'action': 'test' }, function(response) {
        if (response!= '') {
             jQuery('#test-result').html("Restule is generated successfully, copy of result has been sent to your inbox").fadeOut(10000);
             document.getElementById("txtFeedback").value= response;
            //console.log(response.data);
            //alert('POST title: ' + response.data.post_title);
        } else {
            // something didn't go well
            console.log(response.status);
        }
    });
于 2012-06-01T13:03:37.087 回答