i have the file 1.html:
.....
<script src="/libs/jquery-1.3.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
var url0='{$url0}';
var url1='{$url1}';
var url2='{$url2}';
var url3='{$url3}';
var OPEN_ON = false;
openurls= function(){
if(confirm('Opens all?') && OPEN_ON == false){
OPEN_ON = true;
$.ajax({<br/>
type: "POST",
url: "a1.php",
data: jsonData,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
success = true;
},
error: function(msg) {
}
})
if(success) {
window.open(url0)
window.open(url1)
window.open(url2)
window.open(url3)
}
setTimeout("location.reload(true);",3000)
OPEN_ON = false
}
return false
}
Question is:
How do I send url0, url1, url2 and url3 to the file a1.php and there after checking some conditions to send them back.enter code here
You just need to put those
window.open()calls inside the “success:” callback function.Now, once you do that, you’re going to find that the new windows don’t actually open. The browsers are going to block them because they look like aggressive popup ads. Because those
window.opencalls are happening in a context other than a direct user-initiated event (like a button click), they’ll be blocked. That said, here’s what your “success” function should look like:That will “work” as the
window.open()calls will be made, but it won’t “work” in that you won’t actually get popups. You have to make it such that user activity (a “click” somewhere) makes the windows open, not an XMLHttpRequest state change.