search

Home  >  Q&A  >  body text

javascript - Problem with opening window with js

Why can't I open a window after ajax returns?
Code:

    $.ajax( {
        url: '/fb/index.php',
        data:{data: 1},
        type:'post',
        success:function(data) {
                window.open("http://www.jb51.net");
         },
         error : function() {
              console.log("error2");
         }
    });

Why is there no new window opened? Please give me some advice? ?

淡淡烟草味淡淡烟草味2750 days ago485

reply all(2)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-19 10:31:47

    I have encountered this pitfall before. 异步AJAX回调中使用window.open,会被浏览器拦截,把AJAXIt can be solved by changing it to synchronization. The questioner can give it a try.

    reply
    0
  • ringa_lee

    ringa_lee2017-05-19 10:31:47

    I didn’t enter the if, so it didn’t pop up. Try to output data

    reply
    0
  • Cancelreply