我正在使用phonegap并通过本地服务器(phonegap服务器)进行开发。阿贾克斯以前工作得很完美,但现在还没有。现在,当我调用ajax函数时,没有任何反应。我做了什么:
1)编辑config.xml并添加
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
2)编辑AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permissions.NETWORK_ACCESS" />
3)使用jsonp而不是json。它有效,但返回404
4)网址和参数都和以前一样好,问题不在这里
5)apk-build适用于所有android-devices
6)重新安装phonegap app并将android重置为facroty数据
7)我的ajax的例子
app.ajax = {
load: function(method, url, data, onSuccess) {
var beforeSend = function() {
$('body').append($('<i class="loading-icon"></i>'));
};
var onComplete = function() {
$('.loading-icon').remove();
};
var onError = function(jqXHR, textStatus, errorThrown){
console.log(jqXHR);
};
$.ajax({
method: method,
url: url,
data: data,
beforeSend: beforeSend,
success: onSuccess,
complete: onComplete,
error: onError
});
}};
8)节点版本:v0.10.25 Cordova版本:5.1.1
答案 0 :(得分:1)
@KENMAN143, on #3 it clearly says 404 (meaning: file not found). Since you have done this before, I assume you are treating the event deviceready correctly. That leaves the NEW plugin required for whitelist. This is easy to miss since it is NOT on the blog, but posted to the forum.
Notes for upgrading to cli-5.1.1 on PGB
http://community.phonegap.com/nitobi/topics/notes-for-upgrading-to-cli-5-1-1-on-pgb
You can read other missed topics on my blog
(Official) Messages from Phonegap Build Technical Support in the Forum
http://codesnippets.altervista.org/documentation/phonegap/bookmarks/fromSupport.html