Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using server side html+js in phonegap (multiplatform mobile dev)

Phonegap uses html source located in www folder. I was testing what happens if index.html is still in www, but it links to other html that are located in at the server side. It will open the server side html in the web browser instead of handle it as part of the app.

Is there any way to make phonegap work with server side html + js source?

It is not a bad idea if you need to mix usage of libraries (jars + ios libraries), local phonegap html+js with server side dynamic html code (like php output).

thanks.

like image 371
Mariano Latorre Avatar asked Jun 01 '11 22:06

Mariano Latorre


2 Answers

Phonegap is designed to deploy a client, a web app inside a native web view. You can write a server side API for returning any information your app may need and you can modify the DOM using JS. There are great templating solutions out there such as mustache.js. The idea is to write the app fully in JS and retrieve information from the server using any of Ajax implementations in your favourite JS framework. You shouldn't need any dynamic JS. Just information to template and insert into the DOM.

like image 72
sciritai Avatar answered Nov 12 '22 08:11

sciritai


I can't find any reasonable explanation anywhere, but the reason why you can't invoke PhoneGap API's when html is hosted on server-side is because cross-site-scripting issue as the webkit does not allow scripts coming from one domain (i.e. server) be executed on different domain (localhost-device)

like image 2
Jaime Botero Avatar answered Nov 12 '22 07:11

Jaime Botero