我正在尝试使用钛工作室构建简单的应用程序,它将加载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();