Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/399.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未能执行';发送';在';xmlhttprequest';加载失败_Javascript_Jquery_Ajax - Fatal编程技术网

Javascript 未能执行';发送';在';xmlhttprequest';加载失败

Javascript 未能执行';发送';在';xmlhttprequest';加载失败,javascript,jquery,ajax,Javascript,Jquery,Ajax,大家好,当我尝试运行在DevExtreme中创建的应用程序时,我遇到了标题中提到的错误 无论何时在DevExtreme模拟器中运行我的应用程序,它都会正常工作,但当我尝试在手机上运行应用程序时,我会遇到上述错误 function CallService() { var baseAddress = "http://192.168.80.2:8080/WebService/rest/WarehouseServices/"; $.ajax({ type: "G

大家好,当我尝试运行在DevExtreme中创建的应用程序时,我遇到了标题中提到的错误

无论何时在DevExtreme模拟器中运行我的应用程序,它都会正常工作,但当我尝试在手机上运行应用程序时,我会遇到上述错误

    function CallService() {
    var baseAddress = "http://192.168.80.2:8080/WebService/rest/WarehouseServices/";

    $.ajax({
        type: "GET",
        url: baseAddress + 'getPickingOrders',
        contentType: 'applicaiton/xml; charset=utf-8',
        dataType: "xml",
        async: false,
        success: function (xmlObject) {
            xml = xmlObject;
            console.log("succes ramt");
            alert(xml);
            console.log(xml);
            dataSource = GetData(xmlObject);
        },
        error: ErrorOccur
    });

}

我已经为这个问题绞尽脑汁很长时间了,现在我已经没有主意了。

如果运行此脚本的页面不在
http://192.168.80.2:8080
而您的服务器没有为其所在的任何来源启用,您正在运行,这将禁止跨来源ajax。

async:false
为什么?为什么?这会导致糟糕的用户体验。我们可以使用更多的上下文。这段代码在哪里运行?我在这个特定的错误消息中看到的其他问题是关于代码是Chrome扩展的一部分——这里是这样吗?代码运行在一个名为DevExtreme的框架中,该框架也能够模拟代码,就像它是一部手机一样。我不知道你是什么意思成为一个Chrome扩展的一方。该应用程序仅在我的手机上运行时出现此错误,而不是在模拟器中运行。re
async:false
:当然会出现此错误,您只需正确使用回调即可。请查看任何使用
ajax
的示例。关键是在
success
回调中使用结果,而不是在
ajax
调用后的代码中使用。服务器正在接受跨源请求。我在另一台机器上运行了my API,我将尝试在同一台机器上运行API和应用程序,看看这是否解决了问题。感谢您的帮助,通过向服务器添加相应的标头,问题得到了解决。