我使用这个 JavaScript 代码...
function data_addproduct(id){
var hr = new XMLHttpRequest();
var url = "scripts/data_processing.php";
var data = "addproduct";
var vars = "data="+data+"&id="+id;
hr.open("POST", url, true);
hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
hr.onreadystatechange = function() {
if(hr.readyState == 4 && hr.status == 200) {
var return_data = hr.responseText;
document.getElementById("ui_checkout").innerHTML = return_data;
document.getElementById("ui_checkout_mobile").innerHTML = return_data;
data_refreshtotal();
data_refreshproducts();
}
}
hr.send(vars);
document.getElementById("ui_checkout").innerHTML = "<br>Updating...";
document.getElementById("ui_checkout_mobile").innerHTML = "<br>Updating...";
}
但是在 iOS 上的 Safari 中,它没有调用其他两个函数......
data_refreshtotal();
data_refreshproducts();
这很奇怪,因为它在 Chrome for iOS 中运行良好,有人知道如何在 Safari 中修复它吗?
它调用的函数:
function data_refreshtotal(){
var hr = new XMLHttpRequest();
var url = "scripts/data_processing.php";
var data = "refreshtotal";
var vars = "data="+data;
hr.open("POST", url, true);
hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
hr.onreadystatechange = function() {
if(hr.readyState == 4 && hr.status == 200) {
var return_data = hr.responseText;
document.getElementById("ui_total").innerHTML = return_data;
document.getElementById("ui_total_mobile").innerHTML = return_data;
document.getElementById("ui_checkout_notify").innerHTML = "Online EPOS";
}
}
hr.send(vars);
document.getElementById("ui_total").innerHTML = "Updating...";
document.getElementById("ui_total_mobile").innerHTML = "Updating...";
document.getElementById("ui_checkout_notify").innerHTML = "Updating...";
}
function data_refreshproducts(){
var hr = new XMLHttpRequest();
var url = "scripts/data_processing.php";
var data = "refreshproducts";
var vars = "data="+data;
hr.open("POST", url, true);
hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
hr.onreadystatechange = function() {
if(hr.readyState == 4 && hr.status == 200) {
var return_data = hr.responseText;
document.getElementById("ui_checkout").innerHTML = return_data;
document.getElementById("ui_checkout_mobile").innerHTML = return_data;
document.getElementById("ui_checkout_notify").innerHTML = "Online EPOS";
}
}
hr.send(vars);
document.getElementById("ui_checkout").innerHTML = "<br>Updating...";
document.getElementById("ui_checkout_mobile").innerHTML = "<br>Updating...";
document.getElementById("ui_checkout_notify").innerHTML = "Updating...";
}