2
xmlhttpリクエストを使用して2つのAJAXスクリプトがあります。 しかし、彼らはお互いに衝突しています。たとえば、AJAX関数2は関数1のxmlhttp.responseを表示します。私はこれを止める方法があるのだろうかと思っていたのですか?私はすでにxmlhttp.closeを追加しようとしましたが、うまくいきませんでした。 ありがとうございます!XMLHTTPが互いに衝突するのを止めるには?
<script>var hello = setInterval(function()
{
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("main").innerHTML=xmlhttp.responseText;
xmlhttp.close;
}
}
xmlhttp.open("GET","ajax.php?user=" +username,true);
xmlhttp.send();
}, 1000);
</script>
<script>var anotherone = setInterval(function()
{
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("sub").innerHTML=xmlhttp.responseText;
xmlhttp.close;
}
}
xmlhttp.open("GET","ajax.php?user=" +username +"&do=" +option,true);
xmlhttp.send();
}, 1000);
</script>
ありがとうございます!それを完全に忘れてしまった。 – Supra