试试这个例子:
使用js编写这段代码并包含在index.html文件中或者使用javascript标签将这段代码编写到html文件中。您必须在index.hmtl中包含xui-2.3.2.js文件这只是为了减少代码的长度.如果你不使用这个文件,那么 x$ 将不起作用。
x$.data = {};
x$(window).load(function(e){
x$("#returned_information").xhr("http://ws.geonames.org/postalCodeSearchJSON?postalcode=90210&maxRows=10",
{ callback: function(){
var codes = eval("("+this.responseText+")").postalCodes; /* this should be an array */
x$("#returned_information").html(codes[0].placeName);
}
}
);
});
这在 index.html 正文中
<h1 id="returned_information">
Put Stuff in Me
</h1>
最后在外部主机的属性列表文件中授予打开 URL 的权限。在外部主机阵列中添加 *。
我相信它会完美运行。