Ajax cross-domain prompts reload page to get source code

Source: Internet
Author: User
AjaxCross-domain prompts reload page to get source code ">

Ajax Code:

var mobile = Document.myform.b1.value;var Email = Document.myform.b2.value;var Username = document.myform.b3.value + docu Ment.myform.b4.value;var count = 10;var ojj;$.Ajax({type: ' Get ', url: ' http://a.com/app.php ', Data:{username:username,email:email,mobile:mobile},cache:false, DataType: ' Jsonp ', Jsonp: ' Callback ', Jsonpcallback: ' Success_jsonpcallback ', Success:function (e) {if (e== ' Reg_ok ') {$ ( "#reg_fail"). AddClass (' Ldisplaynone '); $ ("#reg_ok"). Removeclass (' Ldisplaynone '); $ ("#popup"). Show (). CSS ("height" , $ (window). Height ()); Count--;if (Count <= 0) {closepopup (); return;} document.getElementById (' Timeshow '). InnerHTML = Count;ojj=settimeout (function () {Prompt ()},1000);} else{$ ("#reg_ok"). AddClass (' Ldisplaynone '); $ ("#reg_fail"). Removeclass (' Ldisplaynone '); $ ("#popup"). Show (). CSS (" Height ", $ (window). Height ()); Count--;if (Count <= 0) {closepopup (); return;} document.getElementById (' Timeshow '). InnerHTML = Count;ojj=settimeout (function () {Prompt ()},1000);}},error:  Function (e) {//console.log (e); Value}});

app.php file

Header ("Access-control-allow-origin: *");//allow cross-domain access first, if * represents all addresses can be accessed if only one address is accessible then write the address directly at the beginning of the full address HTTP.

Json_encode ($STR)

The above describes the Ajax cross-domain prompts to reload the page to get the source code, including the content of Ajax, I hope to be interested in the PHP tutorial friends helpful.

  • Related Article

    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.