window.open与ajax的同步

来源:互联网 发布:深度linux下载 编辑:程序博客网 时间:2024/06/04 18:13

有个需求,在ajax提交新帖子后,要打开刚发的帖子:


$.ajax({            type: "POST",            url: "list.php?action=addArticle",            dataType: "json",            data: data,                   success: function (msg) {   window.open('http://baidu.com');//这里是模拟打开刚发的帖子}});

谁知道,怎么都打不开

把ajax改为同步的,就可以了:

            async: false

  $.ajax({            type: "POST",            url: "list.php?action=addArticle",            dataType: "json",            data: data,            async:false, //同步            success: function (msg) {   window.open('http://baidu.com');//这里是模拟打开刚发的帖子}});

0 0