Jquery:
1 //Get domain name2 functiongetdomain (URL) {3 varA = document.createelement (' A ');4A.href =URL;5Url=A.hostname;6 returnURL;7 }8 9 //Record VisitorsTen functionRecordvisitor () { One varREFERRERMZ =Escape (GetDomain (Document.referrer)); A varHREFMZ =Escape (GetDomain (window.location.href)); -sendinfo= "judgemz=413322&referrermz=" +escape (REFERRERMZ) + "&hrefmz=" +Escape (HREFMZ); - $.ajax ({ theType: "Get", -Asynctrue, -URL: "http://www.mazey.net/config/api/record-receive.php", -data:{judgemz:413322, REFERRERMZ:REFERRERMZ,HREFMZ:HREFMZ}, +DataType: "Jsonp", -JSONP: "Callback", +Jsonpcallback: "Returnfun", ASuccessfunction(data) { atMyarr=data.split ("-|-") - if("0507" ==myarr[0]){ -Console.log (myarr[1]); -}Else if("0215" ==myarr[0]){ -Console.log (myarr[1]); - } in }, -Errorfunction(){ toConsole.log ("Server error!"); + } - }); the } * $ //LoadingPanax Notoginseng$ (document). Ready (function () { - recordvisitor (); the});
Php:
1<?PHP2 require‘.. /config.php ';3 $judgeMz=$_get["Judgemz"];//TODO follow up to do a verification not 413322 error4 $referrerMz=$_get["Referrermz"];5 $hrefMz=$_get["HREFMZ"];6 $visitorIP=GetIP ();7 8 $data= Returnfun ($referrerMz,$hrefMz,$visitorIP); 9 Exit($_get[' Callback ']. ' ('. Json_encode ($data) . ‘)‘); Ten One functionReturnfun ($referrerMz,$hrefMz,$visitorIP) { A $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; the } -?>
Other:
Because Http://www.mazey.cn/config/config-asp/api/record-receive.asp is at home, it seems to be a bit slow to visit. Ready to follow the ASP rewrite PHP back-end write code, originally planned a lot of things, other things this step to finish later.
jquery-php cross-domain Request data