Calling web service using phonegap(ios)

╄→гoц情女王★ 提交于 2019-12-09 19:00:55

问题


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.....


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/9379220/calling-web-service-using-phonegapios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!