Reputation:
I want to call web services in phonegap application. I am using demo code given at
http://wiki.phonegap.com/w/page/32513809/Simple-Web-Service-Consumption-with-PhoneGap-and-XUI
i have created xui.js from link
http://xuijs.com/downloads/xui-2.3.2.js
and tried both putting xui.js, index.html in www/assets and in www folder.
But it is not working for me.Can any one help me please.....
Upvotes: 3
Views: 5229
Reputation: 12641
Try this Example:
Use js to write this code and include in index.html file Or use javascript tag to write this code in html file.You have to include xui-2.3.2.js file in index.hmtl It is just for reducing the length of code.If u do not use this file then x$ will not work.
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);
}
}
);
});
and this in index.html body
<h1 id="returned_information">
Put Stuff in Me
</h1>
At last give permission in property list file in External host to open the URL. Add * in External Host Array.
I m sure it will work perfectly.
Upvotes: 0
Reputation: 7655
Try adding * to the ExternalHosts option in the PhoneGap.plist
This may be the case if your app could not connect to the internet/make xhr calls
Upvotes: 5