使用javascript调用ajax时的图像加载
我想添加加载图像,直到在javascript中单击Onclick函数时得到ajax响应。我使用下面给出的ajax请求函数..我在下面的函数中修复了加载图像的概念使用javascript调用ajax时的图像加载,javascript,ajax,Javascript,Ajax,我想添加加载图像,直到在javascript中单击Onclick函数时得到ajax响应。我使用下面给出的ajax请求函数..我在下面的函数中修复了加载图像的概念 function removeitem(product_id, msg) { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } el
function removeitem(product_id, msg) {
if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById('cartreturn').innerHTML = xmlhttp.responseText;
document.getElementsByClassName('allitem').innerHTML = "Add";
}
}
xmlhttp.open("GET", "/addcart.php?msg=" + msg, true);
xmlhttp.send();
}
我已经评论了一节,你们可以在那个里放置你们的图像加载代码
function removeitem(product_id, msg) {
if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById('cartreturn').innerHTML = xmlhttp.responseText;
document.getElementsByClassName('allitem').innerHTML = "Add";
//Code for removing loader
}
}
xmlhttp.open("GET", "/addcart.php?msg=" + msg, true);
xmlhttp.send();
//Code for adding loader
}
如果(xmlhttp.readyState==4&&xmlhttp.status==200){