Why can't I open a new window in my jquery ajax callback?
to show my problem in a few examples ...
THIS IS WORKS
$.post("SomePage.aspx", { name : "value" },
function (data) {
alert(data);
}, "text");
THIS DOES NOT WORK
$.post("SomePage.aspx", { name : "value" },
function (data) {
window.open("http://www.google.com");
}, "text");
In the first example, I get an alert with what I expect. In the second example, nothing happens. The window does not open. If I add an alert or something before or after calling window.open, the alert works fine, but the window doesn't open. If I add window.open after the $ .post method, the window opens fine (of course it won't help me at all).
I am wondering why I am not able to open the window in the callback. What do I need to do to open the window? I would like to open a window to show some fancy results.
Any help is appreciated, thanks.
a source to share
must work?
try it with window name?
window.open("http://www.google.com", "MyWindow");
according to this post
http://www.javascript-coder.com/window-popup/javascript-window-open.phtml
The syntax for the window.open method is as follows: open (URL, windowName [, windowFeatures])
the second parameter is not optional (of course everything is optional in javascript), maybe something weird is happening in the callback without it?
is it possible to open it in a new tab or behind the current window?
var x = window.open("http://www.google.com", "MyWindow");
x.focus();
a source to share