我正在嘗試使用鈦工作室構建簡單的應用程序,它將加載google.com,但我沒有得到正確的結果。鈦的Webview和httpClient問題
1)我用WebView加載url,但沒有任何顯示,除了白色的屏幕。
2)我使用httpClient,但我總是得到錯誤,我在onerror函數中定義。
這兩種方法都粘貼在下面。我是否必須在tiApp.xml中進行更改,即interent權限?
請幫助我,我該如何做得更好?
注意:我正在使用代理Internet。問題出現在仿真器和設備上。
我加載下面從app.js
var win = Ti.UI.currentWindow;
Ti.App.fireEvent('show_indicator'); //display loading spinner until webview gets loaded
var fbUrl = "http://www.facebook.com";
var extwebview = Titanium.UI.createWebView({
url:fbUrl,
backgroundColor:'#ccc'
});
win.add(extwebview); //adding webview in current window
extwebview.addEventListener('load', function() {
Ti.App.fireEvent('hide_indicator'); //Hide the Loading indicatr
});
---------------方法2 js文件------------ -----
var url ="http://www.google.com.pk";
var xhr = Ti.Network.createHTTPClient({
onload: function() {
// I don't know what to write here.
},
onerror: function(e) {
Ti.API.debug("STATUS: " + this.status);
Ti.API.debug("TEXT: " + this.responseText);
Ti.API.debug("ERROR: " + e.error);
alert('There was an error retrieving the remote data. Try again.');
},
timeout:50000
});
xhr.open("GET", url);
xhr.send();