簡體   English   中英

Phonegap jquery ajax不在電話上工作

[英]Phonegap jquery ajax not working on phone

我最近嘗試為Android構建一個小的Phonegap應用程序。 我設法使一切都在我的電腦上工作,但ajax不能在我的Android手機上工作。

我的jquery ajax請求:

 $.ajax({ async: false, type: 'POST', url: target_url, crossDomain: true, cache: false, contentType: "application/json", dataType: 'jsonp', jsonpCallback: "loginSuccess", error: loginError, }); 

target_url的位置是: http:// username:password@myip/htpassword/login.php我正在使用http身份驗證。 我還啟用了jquery cors支持:

 $.support.cors = true; 

並在config.xml中添加我的ip:

 <access origin="<myip>" /> 

我測試過我的應用程序有互聯網連接! 我嘗試了幾種解決方案,但它們都不適合我。 知道為什么我的應用程序無法從我的手機連接到我的xampp服務器? 提前致謝!

嘗試將auth添加到ajax請求而不是url:

$.ajax({
    async: false,
    type: 'POST',
    url: 'http://myip/htpassword/login.php',
    username: 'username',
    password: 'password',
    crossDomain: true,
    cache: false,
    contentType: "application/json",
    dataType: 'jsonp',
    jsonpCallback: "loginSuccess",
    error: loginError,
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM