ajax support cors,PhoneGap的jQuery的AJAX失败($ .support.cors = TRUE)

jquery.mobile-1.1.1 jQuery的1.7.2.min cordorva-1.9.0

我刚开始接触这个并一直在使用它一个星期了...我已经阅读了每篇文章,尝试了所有我能想到的组合,但仍然没有任何工作。作为最后的手段,我搬到了这一点的PhoneGap和一个真正的浏览器页面,我得到一些不确定的错误:

// if these are NOT set I get the "NO Transport" error

$.support.cors = true;

$.mobile.allowCrossDomainPages = true;

// however, with the above defined (true), the following is the error:

// xhr.statusText = "error"

// textStatus = "error"

// errorThrown.message = "Access Denied"

function login(username, password)

{

var serviceURL = "http://mobile.mydomain.com/";

var strData = "username="+username +"&password="+password;

// setup the paramaters for the ajax call

var ajaxParams = {

type: 'POST',

url: serviceURL + 'mypage.php',

data: strData,

datatype: 'json',

success: function(xmlData, textStatus, xhr) { onLoginOK(xmlData, textStatus, xhr) },

error: function(xhr, textStatus, errorThrown) {

onLoginFailure(xhr, textStatus, errorThrown) },

timeout: 5000,

cache: false

};

// make the ajax call

$.ajax(ajaxParams);

}

function onLoginOK(data, textStatus)

{

// probably not right but haven't gotten this far!

var what = jQuery.parseJSON(data);

alert("Login results: " + data);

if(what.status == "OK")

{

localStorage.setItem("door", what.username);

localStorage.setItem("knock", what.password);

localStorage.setItem("house", what.userid);

}

else if(what.status == "FAILED")

{

alert("Login failed: " +what.text);

}

}

function onLoginFailure(xhr, textStatus, errorThrown)

{

alert("There was an error: The server reported: " + xhr.responseText

+"\nstatus: " +textStatus

+ "\nerror: " +errorThrown);

}

我允许可以访问我的域cordova.xml内

任何人有任何建议?

============================================== ========================== 这是日食:

07-27 09:12:16.612: I/dalvikvm(1295): Could not find method android.webkit.WebView., referenced from method org.apache.cordova.CordovaWebView.

07-27 09:12:16.612: W/dalvikvm(1295): VFY: unable to resolve direct method 3116: Landroid/webkit/WebView;. (Landroid/content/Context;Landroid/util/AttributeSet;IZ)V

07-27 09:12:17.339: I/webviewdatabase(1295): openOrCreateDatabase1

07-27 09:12:17.362: I/CordovaLog(1295): Changing log level to DEBUG(3)

07-27 09:12:17.362: I/CordovaLog(1295): Found preference for useBrowserHistory=false

07-27 09:12:17.378: E/dalvikvm(1295): Could not find class 'android.webkit.WebResourceResponse', referenced from method org.apache.cordova.CordovaWebViewClient.generateWebResourceResponse

07-27 09:12:17.378: W/dalvikvm(1295): VFY: unable to resolve new-instance 451 (Landroid/webkit/WebResourceResponse;) in Lorg/apache/cordova/CordovaWebViewClient;

07-27 09:12:17.378: W/dalvikvm(1295): VFY: unable to find class referenced in signature (Landroid/webkit/WebResourceResponse;)

07-27 09:12:17.386: W/dalvikvm(1295): VFY: unable to find class referenced in signature (Landroid/webkit/WebResourceResponse;)

07-27 09:12:17.386: W/dalvikvm(1295): VFY: unable to find class referenced in signature (Landroid/webkit/WebResourceResponse;)

07-27 09:12:17.386: I/dalvikvm(1295): Could not find method android.webkit.WebViewClient.shouldInterceptRequest, referenced from method org.apache.cordova.CordovaWebViewClient.shouldInterceptRequest

07-27 09:12:17.386: W/dalvikvm(1295): VFY: unable to resolve virtual method 3127: Landroid/webkit/WebViewClient;.shouldInterceptRequest (Landroid/webkit/WebView;Ljava/lang/String;)Landroid/webkit/WebResourceResponse;

07-27 09:12:19.706: W/dalvikvm(1295): No implementation found for native Lcom/carrieriq/iqagent/client/NativeClient;.clientInit (Ljava/lang/Object;)I

07-27 09:12:21.979: I/Database(1295): sqlite returned: error code = 14, msg = cannot open file at source line 25467

07-27 09:12:22.198: I/Web Console(1295): Error: SyntaxError: Unexpected token ILLEGAL at file:///android_asset/www/cordova-1.9.0.js:1012

07-27 09:12:22.347: I/Flex(1295): loadOperatorCode() strOp is AT&T

07-27 09:12:22.347: I/Flex(1295): loadOperatorCode() strMccList is

07-27 09:12:22.347: I/Flex(1295): loadOperatorCode() cr.query strMCC strMNC

07-27 09:12:22.354: I/Flex(1295): loadOperatorCode() mOperatorIndex ==> 1

07-27 09:12:24.167: I/Web Console(1295): **Error** initializing Network Connection: Class not found at file:///android_asset/www/cordova-1.9.0.js:5317

07-27 09:12:26.854: I/Web Console(1295): **JSCallback Error:** Request failed. at file:///android_asset/www/cordova-1.9.0.js:3747

07-27 09:12:28.331: I/Database(1295): sqlite returned: error code = 14, msg = cannot open file at source line 25467

07-27 09:12:28.347: I/Web Console(1295): **Error:** SyntaxError: Unexpected token ILLEGAL at file:///android_asset/www/cordova-1.9.0.js:1012

07-27 09:12:28.386: I/Web Console(1295): **Error** initializing Network Connection: Class not found at file:///android_asset/www/cordova-1.9.0.js:5317

2012-07-26

ppetree

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值