For security reasons, direct cross-domain access is not allowed, and here are two ways to cross-domain.
one, via PHP curl
1 functionCurlpost ($url,$params)2 {3 $postData= ' ';4 foreach($params as $k=$v)5 {6 $postData.=$k. ' = '.$v.‘ & ';7 }8 RTrim($postData, ' & ');9 $ch=curl_init ();Tencurl_setopt ($ch, Curlopt_url,$url); Onecurl_setopt ($ch, Curlopt_returntransfer,true); A -curl_setopt ($ch, Curlopt_header,false); -curl_setopt ($ch, Curlopt_post,Count($postData)); thecurl_setopt ($ch, Curlopt_postfields,$postData); - - $output=curl_exec ($ch); - +Curl_close ($ch); - return $output; + } A at EchoCurlpost ("http://test.com",Array(' name ' = "Tank"));
A lot of people used curl to catch the email address book, but now it is not possible. Ha ha.
Two, submit using jquery Form,ajax
1, download Jquery.form.js
2,JS Code
1$ (' #testform '). Submit (function() {2$( This). Ajaxsubmit ({3Type: ' Post ',//How to submit Get/post4DataType: "JSON",//Data Type5URL: ' Your URL ',//URLs that need to be submitted6Successfunction(data) {//data that is returned after the commit is saved, typically JSON data7 //data can be processed here8Alert (' Submit success! ‘);9 }Ten$( This). Resetform ();//Reset form after submission One }); A return false;//prevent forms from automatically submitting events -});
3,php Code
1 Header // cross-domain permission settings, allowing all Header // only allow test.com to submit data across domains
Cross-domain Access