• ajax请求成功后打开新窗口地址


    转自:http://www.cnblogs.com/linjiqin/p/3148205.html

    复制代码
    jQuery.ajax({
          "type":"post",
          "url":"http://www.baidu.com", 
          "success":function(rel){
               if(rel.isSuccess){ 
                    window.open(rel.url,"_blank");
        }
          }
    });
    复制代码

    这个url请求成功后window.open(rel.url,"_blank");会被浏览器拦截,无法打开新窗口,如果把window.open()放在ajax外面,问题就迎刃而解,代码如下:

    复制代码
    var result="";
     
    jQuery.ajax({
          "type":"post",
          "url":"http://www.baidu.com", 
          "success":function(rel){
               if(rel.isSuccess){ 
      result=rel.url;
                    //window.open(rel.url,"_blank");
        }
          }
    });
     
    if(result.length>0){
          window.open(result,"_blank");
    }
    复制代码
  • 相关阅读:
    Python 基础
    Python 基础
    Python 基础
    Python 基础
    Python 基础
    Python 基础
    Python 基础
    Python 基础
    Python 基础
    Python 基础
  • 原文地址:https://www.cnblogs.com/lvchenfeng/p/5295879.html
Copyright © 2020-2023  润新知