jquery-php cross-domain Request data ____php

Source: Internet
Author: User
Jquery:
 1//Get Domain Name 2 function getdomain (URL) {3 var a = document.createelement (' a ');
 4 a.href = URL;
 5 Url=a.hostname;
 6 return URL; 7} 8 9//Record visitors ' function recordvisitor () {one var referrermz = Escape (GetDomain (Document.referrer)); var hr
EFMZ = Escape (GetDomain (window.location.href));
sendinfo= "judgemz=413322&referrermz=" +escape (REFERRERMZ) + "&hrefmz=" +escape (hrefMz); $.ajax ({type: "Get", Async:true, url: "Http://www.mazey.net/config/api/record         -receive.php ", Data:{judgemz:413322,referrermz:referrermz,hrefmz:hrefmz}, DataType:" Jsonp ", 20 JSONP: "Callback", Jsonpcallback: "Returnfun", success:function (data) {myarr= Data.split ("-|-")-if ("0507" ==myarr[0)) {Console.log (myarr[1));   0215 "==myarr[0]) {Console.log (myarr[1]); 28} 29}, 30      Error:function () {console.log ("Server error!"); 32} 33});  34} 35 36//load of $ (document). Ready (function () {recordvisitor (); 39});

Php:

1 <?php
 2 require '. /config.php ';
 3 $judgeMz =$_get["Judgemz"];//todo follow-up to do a validation is not 413322 error
 4 $referrerMz =$_get["Referrermz"];
 5 $hrefMz =$_get["HREFMZ"];
 6 $visitorIP =getip ();
 7 
 8 $data = Returnfun ($referrerMz, $hrefMz, $visitorIP); 
 9 Exit ($_get[' callback '). ' (' Json_encode ($data). ')'); 
One 
function Returnfun ($referrerMz, $hrefMz, $visitorIP) {     $urlRecordVisitor = ' http:// Www.mazey.cn/config/config-asp/api/record-receive.asp?referrerMz= '. $referrerMz. ' &hrefmz= '. $hrefMz. ' &visitorip= '. $visitorIP;     $resultMz = file_get_contents ($urlRecordVisitor);
return     $resultMz;
?>

Other:

Because Http://www.mazey.cn/config/config-asp/api/record-receive.asp is at home, it seems a bit slow to visit. Prepare to rewrite PHP's back-end writing code in accordance with ASP, originally planned a lot of things, other things this step after you finish.

Link

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.