开发者

How to load external data with PhoneGap App

I'm new to PhoneGap development. Since html and 开发者_运维问答related files reside on in the app on the mobile device itself, there is no compiling done.

How then do I access external dynamic data? At first glance, I assume it's through web services, AJAX, etc.


You right, ajax must be used.

You have a tutorial (with jquery mobile) here:

http://www.giantflyingsaucer.com/blog/?p=2574

It´s posible that you must include extra security policies to make the ajax request, plus in the server side include this header header('Access-Control-Allow-Origin: *'); replace the asterix with your domain.

Good luck!


you can do that using jquery ajax request, but remember to make the crossDomain option to true and to put your domain inside the white list domains inside the plist files


to load external page if you are already online just use ABSOLUTE PATHS in you ajax call:

http://www.yourdomain.xxx/scripts/script.php

if testing locally, just do the same, with

  http://localhost/your_testing_folder/script.php

in both cases find the file CONFIG.XML in the

/project_name/project_name/config.xml 

and add the whitelist URL:

<!-- <content src="http://mysite.com/myapp.html" /> for external pages -->

<content src=www.yourdomain.xxx/" /> for external pages
<content src="http://localhost:8888/" /> <-- this is localhost for local testing purp.
<content src="index.html" />

hope this helps.


Well I think you should use JSON to get dynamic data from server

and then you can fetch it with Jquery and you will be able to perform normal get and post too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜