gpt4 book ai didi

javascript - 我如何为 IE 调试这个 ajax 脚本?

转载 作者:行者123 更新时间:2023-11-28 03:00:57 27 4
gpt4 key购买 nike

我在页面中有一个 AJAX 脚本,在 firefoex 中运行得很好,没有错误,但 IE6 加载页面时状态栏上有一个丑陋的错误图标。我可以修复/调试这个问题的最佳方法是什么?

这是错误报告:

alt text

我多次检查了第 323 行,这是函数:

function checkAvailability(){

var card_select = document.getElementById('card_select').value;
var price_select = document.getElementById('price_select').value;
var num_of_cards = document.getElementById('num_of_cards').value;
var url = 'checkAvailability.php?cardName=' + card_select + '&value=' + price_select + '&amount=' + num_of_cards;

var xmlhttp;
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
alert("Your browser does not support XMLHTTP!");
}

xmlhttp.onreadystatechange = function()
{
if(xmlhttp.readyState == 4 && xmlhttp.responseText) /**** line 323 ****/
{
document.getElementById('submit_button').className = 'hidden';
document.getElementById('div_error_massage').className = 'anounce_div';
document.getElementById('error_massage').innerHTML = xmlhttp.responseText;
document.getElementById('num_of_cards').className = 'red_inputs';
}
else if(isNaN(num_of_cards))
{
document.getElementById('submit_button').className = 'hidden';
document.getElementById('num_of_cards').className = 'red_inputs';
document.getElementById('div_error_massage').className = 'hidden';

}
else if(num_of_cards != "" && !xmlhttp.responseText)
{
document.getElementById('submit_button').className = '';
document.getElementById('error_massage').innerHTML = 'Total: $' + document.getElementById('price_select').value * document.getElementById('num_of_cards').value + '.00';
document.getElementById('div_error_massage').className = 'anounce_div';

}
else
{
document.getElementById('submit_button').className = 'hidden';
document.getElementById('num_of_cards').className = 'red_inputs';
}
}




xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}

最佳答案

在 IE 中,您可以尝试旧的 script debuggerVisual Web Developer Express 。当错误抛出时,进入调试器并检查 xmlhttp

关于javascript - 我如何为 IE 调试这个 ajax 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/930815/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com