我有一个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