The example of this article for everyone to share the AJAX implementation of remote communications for your reference, the specific contents are as follows
First File: HTML
Second file: server-side processing data
<?php/** * Created by Phpstorm. * User:administrator * date:2016-7-21 * time:10:12/if ($_server["request_method"] = = "POST") {//Echo Json_enc
Ode (Array ("=>" "112")); if (isset ($_post["url")) && isset ($_post["username"]) && isset ($_post["password"])) {$result = Postde
Mo ($_post["url"], Array ("username" => $_post["username"), "password" => $_post["password"]);
echo $result; else {echo json_encode (Array ("MSG2 =>"!!!!!!!!!!!!!!!!!!!!! ERROR!!!!!
2 ")); } else {echo json_encode (Array ("MSG" => "error!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"));} function Postdemo ($url, $data
{$query = Http_build_query ($data);
$options = Array ("http" => Array ("header" => "content-type:application/x-www-form-urlencoded\r\n"). "Content-length:". Strlen ($query).
"\ r \ n".
"user-agent:myagent/1.0/r/n", "Method" => "POST", "Content" => $query)); $content = Stream_context_creAte ($options);
$result = File_get_contents ($url, False, $content);
return $result; }//echo Postdemo ("http://192.168.4.101:90/PHPStudy4/server.php", Array ("username" => "admin", "Password" => "
admin "));
where "url": "http://192.168.4.101:90/PHPStudy4/server.php", this URL is our access to the remote address.
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.