Calling web service using phonegap(ios)

微笑、不失礼 提交于 2019-12-04 12:41:07

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

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.

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