Home > Article > Backend Development > ajax cross-domain prompt Reload the page to get the source code
ajaxCode:
var mobile = document.myform.b1.value; var email = document.myform.b2.value; var username = document.myform.b3.value + document.myform.b4.value; var count = 10; var ojj; $.<strong>ajax</strong>({ 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); //有值 } });
app.php 文件
header("Access-Control-Allow-Origin: *");//First Cross-domain access is allowed. If it is *, it means that all addresses can be accessed. If it can only be accessed by a certain address, write the address directly and write the address starting with http.
json_encode($str)
The above introduces the ajax cross-domain prompt. Reload the page to obtain the source code, including ajax content. I hope it will be helpful to friends who are interested in PHP tutorials.