Why would you want to do this? There are many reasons for calling remote scripts and functions, for example:
- You want a clear separation between the front end and back end of your app
- You want to create a RESTful API that allows third party users to access information on your site
- You want to connect a mobile app to your Web back end
The following video will explain how to go about calling a remote PHP script. The code in the video is given below.
The code for the remote PHP script is as follows. As you can see, it’s quite simple!
<?php header("Access-Control-Allow-Origin: *"); $id = "1234"; $name = $_GET['name']; $dataArray = $id; $dataArray = $name; echo json_encode($dataArray); ?>