jquery ajax在phonegap中无法正常工作

时间:2015-10-27 10:30:01

标签: javascript jquery ajax cordova

经过长时间的谷歌搜索,我没有得到任何解决方案。我在config.xml中尝试的东西是:

<access origin="*" />

<access origin="http://abc.xyzzds.biz/" />

此处HTML代码:

   $.ajax({
            type: "POST",
            url: "http://abc.xyzzds.biz/web_service/login",
            data: 'user_name=' + u + '&password=' + p,
            crossDomain: true,
            contentType: "application/x-www-form-urlencoded",
            async: false,
            dataType: 'json',
            processData: false,
            cache: false,
            headers: {
                "Authorization": "Basic " + btoa('rickmams' + ":" + 'advisor11')
            },
            success: function (data) {
                console.log('****success**');
                var data = jQuery.parseJSON(data);
                switch (data.status) {
                    case 'SUCCESS':
                        window.location = "test.html";
                        break;
                    case 'ERROR':
                        navigator.notification.alert('Error :- ' + data.message);
                        break;
                    default:
                        navigator.notification.alert('Error :- ' + data.message);
                }

            },
            error: function (xhr, status, error) {
                console.log('****error**');
                console.log(xhr);
                navigator.notification.alert(status + ' ' + xhr.responseText, alertDismissed, 'Error');
            },
        });

CLI中的输出: -

enter image description here

0 个答案:

没有答案