2011-11-28 69 views
0

我通過ajax發佈自己的價值,並使用響應的細節將會顯示出來。我在檢索數據時遇到了問題。但我不知道哪裏有錯,然後這是經常顯示錯誤getiing 「使用XMLHTTP時出現問題:\ n」;,同時使用ajax獲取錯誤消息來提取數據

in all browsers mainly in the chrome,could any one help me... 

這是我的代碼,

var xmlHttp; 

try { 
    // Firefox, Opera 8.0+, Safari 
    xmlHttp = new XMLHttpRequest(); 
} catch (e) { 
    // Internet Explorer 6+ 
    try { 
     xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); 
    } catch (e) { 
     // Internet Eplorer 5 
     try { 
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
     } catch (e) { 
      alert("Your browser does not support AJAX. Download a newer browser to view this page."); 
      return false; 
     } 
    } 
} 

// insert server response into HTML element 
xmlHttp.onreadystatechange = function() { 
    if (xmlHttp.readyState == 4) { 
     if (xmlHttp.status == 200) { 
      MM_check_session(xmlHttp.responseText); 
      var b_gc = document.getElementById(insert).value; 
      document.getElementById(insert).value = xmlHttp.responseText; 
      var shippingid = getCheckedValue('checkout_form', 'shippingid'); 
      closeMessage(); 
      MM_calc_shipping(shippingid); 
      if (b_gc == xmlHttp.responseText) { 
       MM_register(); 
      } else { 
       error = 1; 
       document.getElementById('payment_error').innerHTML = xmlHttp.responseText; 
       document.getElementById(insert).value = ''; 
      } 
     } else { 
      closeMessage(); 
      alert("We can't process your request.Please refresh(reload) the page to proceed further:\n" 
        + xmlHttp.statusText); 
     } 

    } 
} 
displayStaticMessage(
     '<img src=' + config_MM_loader_image_path + ' alt=\'loading...Please wait\'>', 
     false); 

xmlHttp.open("POST", serverScript, true); 
xmlHttp.setRequestHeader('Content-type', 
'application/x-www-form-urlencoded'); 
xmlHttp.setRequestHeader('Content-length', parameters.length); 
xmlHttp.setRequestHeader('Connection', 'close'); 
xmlHttp.send(parameters); 

任何幫助

+1

在代碼中找不到任何產生上述錯誤消息的地方(「使用XMLHTTP時出現問題:\ n」;)。 – mephisto123

回答