2012-03-28 68 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

相關問題