Open a new window in Ajax to prevent browser Blocking

Source: Internet
Author: User

1. Open the new window, window. open (), which is not blocked by the browser. But in the Ajax method, the new window is blocked, as shown below:

Function mfopen (ID, name) {jquery. Ajax ({type: "Get", datatype: "text", URL: "userlogin. aspx? Method = init ", success: function (MSG) {var JSON = eval (" ("+ MSG +") "); If (JSON. result = "100") {If (JSON. isagtuser! = "0") {jerppopup ("not qualified", 'No. aspx ', 415, 90, function () {});} else {var cid = ID; var cname = Name; var url = 'chuli. aspx? Id = '+ CID +' & name = '+ escape (cname) +' & num = math. random () '+ ''; window. open (URL) ;}} else {jerppopup ("You have not logged on. Please log on first", 'login. aspx? Fun = pingjiaagent2 ', 410,180, function (){});}}});}

2. By default, Ajax is asynchronous and modified to synchronous execution. This can solve the problem that a new window is blocked by the browser, as shown below:

Function mfopen (ID, name) {jquery. Ajax ({type: "Get ",Async: false,Datatype: "text", URL: "userlogin. aspx? Method = init ", success: function (MSG) {var JSON = eval (" ("+ MSG +") "); If (JSON. result = "100") {If (JSON. isagtuser! = "0") {jerppopup ("not qualified", 'No. aspx ', 415, 90, function () {});} else {var cid = ID; var cname = Name; var url = 'chuli. aspx? Id = '+ CID +' & name = '+ escape (cname) +' & num = math. random () '+ ''; window. open (URL) ;}} else {jerppopup ("You have not logged on. Please log on first", 'login. aspx? Fun = pingjiaagent2 ', 410,180, function (){});}}});}

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.