我有問題與cordova/phonegap/ajax
來自網頁的請求。由於該應用正在與phonegap
developer-app在手機上運行並完美地發送ajax requests
。我認爲這跟permissions/plugins
有什麼關係。但是,當我使用cordova
安裝應用程序不發送任何東西,整個ajax request
回報:Phonegap AJAX請求undefined
readyState: 0
responseText: undefined
status: 0
text status: error
error
在3210我設置
<access origin="*" />
和AndroidManifest.xml
心中已經設定
<uses-permission android:name="android.permission.INTERNET" />
這裏是ajax request
本身
$.ajax({
method: "GET",
crossDomain: true,
dataType: 'json',
url: 'http://mywebsite.com/projectname/index.php',
data: { x: userLocation.latitude, y: userLocation.longitude },
success: function(data){
alert("Success: "+ data);
},
error: function(xhr, textStatus, err) {
alert("readyState: " + xhr.readyState);
alert("responseText: "+ xhr.responseText);
alert("status: " + xhr.status);
alert("text status: " + textStatus);
alert("error: " + err);
}
});
包括cordova.js
到項目:
<script type="text/javascript" src="cordova.js"></script>
<script src='js/jquery.js'></script>
<script>
$(document).bind('mobileinit', function() {
$.mobile.changePage.defaults.changeHash = false;
$.mobile.hashListeningEnabled = false;
$.mobile.pushStateEnabled = false;
});
</script>
<script ...here comes js file where ajax is called out
設置這些沒有工作,要麼
$.support.cors = true;
$.mobile.allowCrossDomainPages = true;