In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces Ajax how to achieve a successful request to open a new window address, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
The key code is as follows:
JQuery.ajax ({"type": "post", "url": "http://www.baidu.com"," success ": function (rel) {if (rel.isSuccess) {window.open (rel.url," _ blank ");})
After the url request is successful, window.open (rel.url, "_ blank"); will be blocked by the browser and cannot open a new window. If you put window.open () outside the ajax, the problem will be solved as follows:
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");}
Let's take a look at opening a new window after the Ajax response
There is a function in the recent development, after clicking a link, to determine whether the current user is logged in, if not, need to pop up a login dialog box, after the user logs in, and then open the link to the Url in a new window (tab).
Don't say much, just post the code:
$(document) .delegate ("a", "click", function () {var actionUrl = $(this) .attr ("href"); var ssoAction = function () {window.open (actionUrl,'_ blank');}; if (isLogin ()) {ssoAction () } else {popup.show ({login:function () {$.ajax ({type: "post", dataType: "json", url: "/ Account/Login", data: $("frmLogin"). Serialize (), / / change the sending method to synchronization to prevent pop-up pages from being intercepted by browsers async: false, success: function (oData) {ssoAction ();});} return false;})
Important: you need to use synchronous submission, use asynchronous submission, and open a new window (tag) in callback, which will be considered malicious by the browser.
Thank you for reading this article carefully. I hope the article "Ajax how to open a new window address after a successful request" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.