jquery ajax post数据并获取返回值进行操作方法
这里向API接口POST访客的来源页面信息,然后通过API接口进行判断处理,输出1则跳百度,输出0则跳谷歌,其他情况则嵌入bnxb.com的IFRAME
<script src="https://cdn.bootcss.com/jquery/3.0.0/jquery.min.js"></script>
<script>
$(function () {
var ref=document.referrer;
$.post("http://1.1.1.1/api.php", {ref:ref}, function (data) {
if(data == 1){
window.location.href = 'http://www.baidu.com/index.html';
}else if(data == 0){
window.location.href = 'http://www.google.com';
}else{
var html = "<center><iframe src=https://www.bnxb.com/ align=\"center\" frameborder=\"0\" scrolling=\"no\" marginwidth=\"1\" marginheight=\"1\" width=\"1002\" height=\"3500\"></iframe></center>";
$(document.body).before(html);
}
});
});
</script>顶(0)
踩(0)
- 最新评论
