I am just a beginner in Web Development. But I got encountered with a interesting problem here we go.
Problem statement:
When I click on the Paragraph tag, I am making an Ajax call and it is opening in a new window, but the response i am getting from that called URL is not getting alerted in my current window. And also i wanted to close the ajax called window. I have Simplesaml authentication code in Filename.php
My code is as below Login.html:
<p>SSO</p>
Ajax call:
$('p').on("click", function(){
var newWindow = window.open("https://example.com/Filename.php", "new window", "width=400, height=500");
$.ajax({
url: newWindow,
async:false,
success: function(res){
alert(res);
console.log(res);
newWindow.close();
}
});
})
-
window open has nothing to do with Ajax call, not sure where you learned that from.epascarello– epascarello2018年06月27日 13:19:55 +00:00Commented Jun 27, 2018 at 13:19
-
newWindow is not an urlEmeeus– Emeeus2018年06月27日 13:39:23 +00:00Commented Jun 27, 2018 at 13:39
1 Answer 1
You need to use the url string in the url property of your AJAX call. Like this:
$.ajax({
url: "https://example.com/Filename.php",
async:false,
success: function(res){
alert(res);
console.log(res);
newWindow.close();
}
});
})
https://developer.mozilla.org/en-US/docs/Web/API/Window/open