我有一个问题,我正在使用Chrome浏览器中的ASp.Net Web应用程序@ 123buy.com,出于某种原因,当我进入产品页面,然后点击添加产品时,它无法正常工作其他浏览器。我有两个需要在Chrome中运行的功能,就像在其他浏览器中一样。当它调用它时,HTTP.Status始终为零,这会破坏其他功能,例如当用户点击添加到产品时,它会显示成功或失败的位置,这在chrome中无法让Chrome返回状态
调用:AddToCart.aspx?VarId
function submitProduct(varId) {
xmlhttp = null;
var status = jQuery("#loader");
try {
if (window.XMLHttpRequest) {// code for IE7, Firefox, Opera, etc.
xmlhttp = new XMLHttpRequest();
}
else if (window.ActiveXObject) {// code for IE6, IE5
xmlhttp = new ActiveXObject("MSXML2.XMLHTTP.3.0");
}
else {
if (status) {
status.attr('class', 'div_error_container_big').attr('innerHTML',
'Your browser does not support XMLHTTP.').slideDown('fast').delay(2000).slideUp('fast');
}
}
if (xmlhttp != null) {
xmlhttp.onreadystatechange = state_Change;
var params = "varId=" + varId;
if (status) {
status.attr("innerHTML", "<img style='padding-top:5px;' src='images/ajax-loader-2.gif' />").show();
}
var url = "addtocart.aspx?" + params;
xmlhttp.open("GET", url, true);
xmlhttp.setRequestHeader("Content-type", "text/plain;charset=UTF-8");
xmlhttp.send(null);
}
}
catch (ex) {
alert(ex.toString());
}
}
function state_Change() {
if (xmlhttp.readyState == 4) {
var status = jQuery("#loader");
if (xmlhttp.status == 200 || xmlhttp.statusText == "OK") {
if (status) {
status.attr("innerHTML", "");
status.hide();
}
var response = xmlhttp.responseText;
if (response != "") {
var arr = response.split('|');
if (arr && arr.length == 3) {
if (status) {
status.attr("innerHTML", "<div class='innerLoaderDiv'>Item was successfully added to your cart</div>"); //arr[1]
jQuery('#ctl00_lblCartItems').attr("innerHTML", " (<b>" + arr[0] + "</b>)");
jQuery('#ctl00_lblCartItems').tipsy({ gravity: 'n', html: true, title: function () { return arr[2]; } }); //
status.fadeIn(1000).delay(1000).fadeOut(1000);
}
}
}
else {
if (status) {
status.attr("innerHTML", "<span style='color:red;'>Sorry, an error has occured.</span>");
status.fadeIn(1000);
}
}
}
else {
if (status) {
status.attr("innerHTML", "");
}
}
}
}
通话:Product.aspx?VarId
function GetSynchronousJSONResponse(url, postData) {
xmlhttp = null;
var status = jQuery("#loader");
try {
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
if (new ActiveXObject("Microsoft.XMLHTTP"))
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
else
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
else {
if (status) {
status.attr('class', 'div_error_container_big').attr('innerHTML',
'Your browser does not support XMLHTTP.').slideDown('fast').delay(2000).slideUp('fast');
}
}
if (xmlhttp != null) {
// xmlhttp.onreadystatechange = state_Change;
if (status) {
status.attr("innerHTML", "<img style='padding-top:5px;' src='images/ajax-loader-2.gif' />").show();
}
xmlhttp.open("POST", url, false);
xmlhttp.setRequestHeader("Content-Type", "application/json; charset=utf-8");
xmlhttp.send(postData);
var responseText = xmlhttp.responseText;
return responseText;
}
}
catch (ex) {
alert(ex.toString());
}
}