简体   繁体   中英

How can 2 different servers communicate in the same “machine”?

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?

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM