admin管理员组

文章数量:1400445

Hello guys I'm getting the error mentioned in the headline when i try to a run my app created in DevExtreme.

Whenever Í run my app in the DevExtreme simulator it works as it should but when I try to run the app on my phone I get the mentioned error.

    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
    });

}

I have been strugling with this problem for a long time now and I'm out of ideas.

Hello guys I'm getting the error mentioned in the headline when i try to a run my app created in DevExtreme.

Whenever Í run my app in the DevExtreme simulator it works as it should but when I try to run the app on my phone I get the mentioned error.

    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
    });

}

I have been strugling with this problem for a long time now and I'm out of ideas.

Share Improve this question asked Apr 5, 2016 at 8:17 user5396725user5396725 7
  • async: false Why? Why? It makes for a horrible UX. – T.J. Crowder Commented Apr 5, 2016 at 8:21
  • We could use more context. Where is this code running? The other SO questions I see with this specific error message talk about the code being part of a Chrome extension -- is that the case here? – T.J. Crowder Commented Apr 5, 2016 at 8:23
  • The code is running in a framework called DevExtreme which also able to simulate the code as it would be a a mobile phone. I'm not sure what you mean about being a party of a Chrome extension. The app is only giving this error when running on my phone and not in the simulator – user5396725 Commented Apr 5, 2016 at 8:38
  • Re async: false: Sure it will, you just need to use the callback correctly. – T.J. Crowder Commented Apr 5, 2016 at 8:47
  • 1 Look at just about any example of using ajax. The key thing is to use the result from within the success callback, not to do it in code following the ajax call. – T.J. Crowder Commented Apr 5, 2016 at 9:12
 |  Show 2 more ments

1 Answer 1

Reset to default 1

If the page where this script is running isn't on http://192.168.80.2:8080 and your server doesn't enable Cross-Origin Resource Sharing for whatever origin it's on, you're running into the Same Origin Policy, which prohibits cross-origin ajax.

本文标签: javascriptFailed to execute 39send39 on 39xmlhttprequest39 failed to loadStack Overflow