ajax 跨域提示 重新载入页面以获取源代码

来源:互联网 发布:软件定义网络服务商 编辑:程序博客网 时间:2024/05/18 03:07


ajax代码:

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;$.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);  //有值    }});

app.php 文件

header("Access-Control-Allow-Origin: *");//首先允许跨域访问,如果是*代表所有的地址都可以访问如果只能是某个地址访问则直接写地址 写全地址http开头的地址。

json_encode($str)

0 0
原创粉丝点击