Needless to say, the key code looks like this:
Jquery.ajax ({
"type": "Post",
"url": "Http://www.baidu.com",
"Success": function (rel) {
if ( rel.issuccess) {
window.open (rel.url, "_blank");
}
this URL request after successful window.open (Rel.url, "_blank"), will be blocked by the browser, unable to open a new window, if the window.open () on the outside of Ajax, the problem is solved , the code is 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");
}
Look below to open a new window after an AJAX response
Recent development has a function, click on a link, to determine whether the current user is logged in, do not log in, you need to pop up a login dialog box, the user login, and then in a new window (tag) to open the link to the URL.
No more, 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 (),
//Send in sync, Avoid pop-up pages being blocked by browsers
Async:false,
success:function (oData) {
ssoaction ();}
})
;} return false;
});
Focus: Need to use synchronous commit, use asynchronous commit, callback inside open new Window (label), can be considered by the browser is malicious behavior.