Javascript jquery ajax在phonegap中无法正常工作
经过长时间的谷歌搜索,我没有找到任何解决办法。我在config.xml中尝试了以下内容:Javascript jquery ajax在phonegap中无法正常工作,javascript,jquery,ajax,cordova,Javascript,Jquery,Ajax,Cordova,经过长时间的谷歌搜索,我没有找到任何解决办法。我在config.xml中尝试了以下内容: <access origin="*" /> <access origin="http://abc.xyzzds.biz/" /> CLI中的输出:- 数据:{'user_name':u,'password':p}谢谢您的评论,但它不起作用@madalinivascuCould是同一来源策略请参见此 $.ajax({ type: "POST",
<access origin="*" />
<access origin="http://abc.xyzzds.biz/" />
CLI中的输出:-
数据:{'user_name':u,'password':p}
谢谢您的评论,但它不起作用@madalinivascuCould是同一来源策略请参见此
$.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');
},
});