Feeling frustrated and seeking help.
I am currently executing this particular script:
<script type="text/javascript" charset="utf-8>
jQuery(window).ready(function(){
//alert('running');
var sold = false;
var leads = [
["one", 120],
["two", 0]
];
jQuery.each(leads, function(index, value) {
var _data = "";
jQuery.ajax({
url: "/wp-content/plugins/cUrl/submit_lead.php?lead=" + value[0],
dataType: "json",
//contentType: "application/json; charset=utf-8",
timeout: value[1] * 1000, //Yes i need to wait 120 seconds for "one"
async: false,
cache: false
}).success(function(data) {
_data = data;
console.log(data.status + " Lead: "+ value[0]);
if (data.status == "sold") {
sold = true;
jQuery.ajax({
url: "/wp-content/plugins/cUrl/submit_lead.php?resetSession",
dataType: "json",
//contentType: "application/json; charset=utf-8",
async: false,
cache: false
}).success(function() {
//Silence is golden.
});
window.location.href = data.link;
}
}).error(function(jqXHR, textStatus){
console.log("ERROR: " + textStatus + " Lead: " + value[0]);
});
if (_data.status == "sold") {
return false;
}
});
if (!sold) {
//If we get here, None of the leads were sold.
jQuery.ajax({
url: "/wp-content/plugins/cUrl/submit_lead.php?resetSession",
//contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
cache: false
}).success(function(data) {
//Silence is golden.
});
window.location.href = '/thank-you.php';
}
});
</script>
This specific script collects information and submits it to submit_lead.php. The response will include a status, a message, and a link. Once the link is received, the script should call the same script with ?resetSession and then redirect the user to the obtained link.
I disabled synchronous calls because I require a response from "one" before moving on to "two". If a link is received for one lead, there is no need to proceed to the next lead.
When running the script in Firefox or Chrome, everything works smoothly with animations indicating progress as requests are processed. However, in IE8 or Safari, the page partially loads and remains static until the ajax response is received, after which it suddenly springs into action and redirects.
I have experimented with using `window.ready` and `document.ready`, but without success.
Any advice or suggestions would be greatly appreciated.
Thank you for taking the time to read this.