2012-03-28 64 views
2

我正在使用phonegap cordova-1.5.0.js和jar。 并使用PhoneGap的-插件科尔多瓦与jsOAtuh.1.3.3.js
未被捕获的模块xhr未找到cordova-1.5.0.js

我收到错误消息:
“未捕获模块XHR不是文件中找到:///android_asset/www/cordova-1.5。 0.js“

每当我尝试创建OAuth对象。

我有以下几点参考: https://github.com/bytespider/jsoauth
这里是我的代码。



    var config_google={ 
     var config_google={ 
     consumerKey: "{removed}", 
     consumerSecret: "{removed}", 
     requestTokenUrl: "https://www.google.com/accounts/OAuthGetRequestToken?scope={removed}", 
     authorizationUrl:"https://www.google.com/accounts/OAuthAuthorizeToken", 
     accessTokenUrl:"https://www.google.com/accounts/OAuthGetAccessToken" 
    }; 

    function authservice(service){ 
     //alert(service); 
     curfunc = "authservice"; 
     str_service = service; 
     if (service === 'google'){ 
      oauth = new OAuth(config_google); 
     }else if.... 

    ........ 
    } 

我以前用phonegap-1.4.1.js(以前的版本)的代码,它的工作原理。我在1.4.1和1.5.0上搜索了xhr,他们都没有xhr,但是有一些注释引用。不完全确定为什么改变1.5.0,它会禁用代码。我需要使用1.5.0是因为我需要使用childbrowser插件。

你能指出我正确的方向吗?

在此先感谢。

回答

0

我有一个破解它的工作。 802行的require(“xhr”)认为某人在某处注册了它,但在登录时,我没有看到有人曾经呼叫Cordova的“define”函数进行注册。

所以,如果你注释掉那些3行代码,这是一个快速的方法来得到它回落到XMLHttpRequest的,像这样(约请求构造函数中800线):

if (typeof global.Titanium !== 'undefined' && typeof global.Titanium.Network.createHTTPClient != 'undefined') { 
    XHR = global.Titanium.Network.createHTTPClient(); 
//} else if (typeof require !== 'undefined') { 
// // CommonJS require 
// XHR = new require("xhr").XMLHttpRequest(); 
} else { 
// W3C 
    XHR = new global.XMLHttpRequest(); 
} 
+0

谢谢JesterXL也Rob G. jsOAuth的原作者。你们很生气。 :)感谢您解决我的问题。 – 2012-04-04 04:50:55