【发布时间】:2012-11-22 12:47:37
【问题描述】:
我正在尝试使用 Titanium Studio 构建简单的应用程序,该应用程序将加载 google.com,但我没有得到正确的结果。
1) 我使用 WebView 加载 url 但除了白屏没有显示。
2) 我使用了 httpClient,但总是遇到我在 onerror 函数中定义的错误。
两种方法都粘贴在下面。我是否必须在 tiApp.xml 中进行更改,即 interent 权限?
请帮帮我,我怎样才能做得更好?
注意:我正在使用代理互联网。模拟器和设备都出现问题。
我正在从 app.js 加载以下 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
});
---------------方法二------
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();
【问题讨论】: