1

First of all i would like to apologize if my question doesnt make so much sense , as i am very new to these concepts.

We are building a mobile web application which has 2 parts.

1) The "back-end" server part which i am currently building , that is php-mysql , where i take care of all data to be stored in the database , i make queries etc.

2) The "front-end" part. This will be developed in jquery and will be the mobile web site. This "web site" will be available through a mobile application by opening an "in application browser" . Note that i ve never used jquery before. The architecture of the application was that every time a mobile phone connects to the web-site (jquery) , we send along with the URL the deviceID of the phone. Then when the user does anything at the site like subscribe to some kind of events , i "send" this subscriptions to my "back-end" server and save them to database.

My question :

As i said i dont know jquery. Both jquery and php will be deployed in the same machine. That means (i guess..) that i could through jquery have instant access to my databases and save users subscribtions. However because i dont know jquery i want to do the minimum staff with it. So i would like to pass these subscriptions to my php scripts and handle them there.

How do i "pass" the subscriptions between the 2 servers that are deployed in the same machine? Do i need to make an http post request? Thats what i do to make the mobile devices , connect with the server but i guess that when they are in the same machine there should be another way right? We use HTTP requests for remote connections right?

donparalias
  • 1,773
  • 13
  • 35
  • 59

1 Answers1

4

Even though jQuery and PHP are hosted on the same machine, it is not executed on the same machine.

PHP is executed on the local machine and it's results are sent to the client (in app browser). jQuery is sent to the client and executed at the client.

So PHP is executed on server and jQuery at client. To facilitate the communication you should use for example jQuery.ajax http://api.jquery.com/jQuery.ajax/ or for example jQuery.getJSON http://api.jquery.com/jQuery.getJSON/

nvanesch
  • 2,360
  • 11
  • 21
  • Hmm , so what you are saying is that i actually need to make an http POST request from the jQuery to the php and handle my data with php? – donparalias May 03 '13 at 07:48
  • Either post or get, or you might even want to consider RESTfull (http://stackoverflow.com/questions/671118/what-exactly-is-restful-programming). But basically you will have to treat it as 2 completely seperate things. The jquery should do requests to the php scripts to get and/or post the data. – nvanesch May 03 '13 at 07:50
  • great :) that was exactly what i was hoping for. I do understand now that jquery is for the client-side and the php for the server-side – donparalias May 03 '13 at 07:56