我有一個Phonegap/Jquery移動應用程序,我試圖爲Android打包,但是我使用的目標SDK不允許Ajax /跨域請求。 簡而言之,這些請求適用於Android 4.0.3(API 15),這是最新的,但不適用於Android 2.3.3(API 10),這是我需要與Galaxy Tablet兼容的。 我很難調試這個,因爲我無法看到實際的錯誤,因爲我被封裝在phonegap和不能用戶Firebug/Chrome網絡工具。在developer.android.com上我沒有任何運氣。 我已經嘗試了位於http://jquerymobile.com/test/docs/pages/phonegap.html的步驟,其中包括 $ .mobile.allowCrossDomainPages = true; $ .support.cors = true。Ajax請求無法在特定的Android SDK上工作
這也沒有工作。 任何人都可以幫助我,我不知道還有什麼要嘗試。 謝謝!
以下是代碼的一個簡單示例。請注意,它返回成功= true,但命中「響應不是XML元素」的錯誤:
return $.soapRequest({
url: url,
namespace: 'testns',
returnJson: false,
shortMethod: 'methodname',
method: 'longmethodname',
params: params || {},
success: function(data) {
if (data && data.documentElement) {
// hits this on Android SDK 15
if (successFn) {
return successFn(data.documentElement);
}
}
else {
// hits this on Android SDK 10
return fail("Response is not an XML element!");
}
},
error: function(str) {
return fail(str);
}
看看此http://aurir.wordpress .com/2010/03/22/tutorial-getting-android-emulator-working-with-fiddler-http-proxy-tool/ 此外,這可能也有幫助http://jsconsole.com/remote-debugging.html – bmurmistro 2012-04-13 13:19:43