嘗試這個例子:
用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屬性列表文件的最後授予權限。 在外部主機陣列中添加*。
我相信它會完美的工作。
感謝男人......其工作 – mithilesh 2012-02-21 15:48:54
嗨,我解決了這個問題後,我寫了一個關於在PhoneGap中調用Web服務的博客http://kmithi.blogspot.in/2012/02/callling-web -Services-in.html? – mithilesh 2012-02-26 14:09:35
@ghostCoder,如何android,我必須修復。由於跨腳本限制而獲得例外。那麼,我必須在Android中將該*添加到ExternalHosts選項。謝謝。 – Ahamed 2012-03-19 09:37:11