Ajax调用在模拟器中工作,但在设备上不工作

时间:2016-04-06 08:50:47

标签: android jquery ajax devextreme

我在使用的应用中遇到了问题。问题是该应用程序在Devextreme的模拟器中完美运行。如果我尝试在手机上运行应用程序,则AJAX调用会触发我的错误功能。我的代码如下:

Application1.home = function(params) {
    var dataSource;
    var xml;
    CallService();

    function CallService() {
        $.ajax({
            type: "GET",
            url: baseAddress + 'getPickingOrders',
            dataType: "xml",
            async: false,
            success: function(xmlObject) {
                xml = xmlObject
                console.log("succes ramt");
                dataSource = GetData(xml);
            },
            error: ErrorOccur
        });
        console.log(dataSource);
    }

    function ErrorOccur() {
        alert("Error ramt");
    }

    function GetData(xmlDoc) {
        var customerNumber = xmlDoc.getElementsByTagName('customerNumber');
        var getOrderNumber = xmlDoc.getElementsByTagName('orderNumber');
        var getDeliveryMethod = xmlDoc.getElementsByTagName('deliveryMethod');
        console.log("Datasource alerttt " + dataSource);
        console.log(customerNumber);
        console.log(getOrderNumber);
        console.log(getDeliveryMethod);

        var txt = [];
        var len = customerNumber.length;
        for (var i = 0; i < len; i++) {
            txt.push({
                customerNumber: customerNumber[i].childNodes[0].nodeValue,
                getOrderNumber: getOrderNumber[i].childNodes[0].nodeValue,
                getDeliveryMethod: getDeliveryMethod[i].childNodes[0].nodeValue,
            });
        }
        return txt;
    }

    var viewModel = {
        dataSource: dataSource,
        onRowClick: function(info) {
            info.rowElement.hasClass('clicked') ? info.rowElement.removeClass('clicked') : info.rowElement.addClass('clicked')
        },
    };

    return viewModel;
};

0 个答案:

没有答案