Hi, I am trying to send 2 ajax requests in the same html web page.
The first(findteams.php) works and the second(submitPick) will send, but not receive any data.
Here is my code:
[CODE]
<script type=”text/javascript”>
function getXMLHTTP() {
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject(“Microsoft.XMLHTTP”);
}
catch(e){
try{
xmlhttp = new ActiveXObject(“Msxml2.XMLHTTP”);
}
catch(e1){
xmlhttp=false;
}
}
}
return xmlhttp;
}
function getTeams(strURL) {
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
// only if “OK”
if (req.status == 200) {
document.getElementById(‘displayTeams’).innerHTML=req.responseText;
} else {
alert(“There was a problem while using XMLHTTP:n” + req.statusText);
}
}
}
req.open(“GET”, strURL, true);
req.send(null);
}
}
function submitPick()
{
var xmlhttp;
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(“myDiv”).innerHTML=xmlhttp.responseText;
}
}
var home = document.getElementById(‘home’).options[document.getElementById(‘home’).selectedIndex].value;
var away = document.getElementById(‘away’).options[document.getElementById(‘away’).selectedIndex].value;
var score = document.getElementById(‘score’).options[document.getElementById(‘score’).selectedIndex].value;
var queryString = “&score=” + score + “&home=” + home + “&away=” + away;
xmlhttp.open(“GET”, “update.php” + queryString,true);
xmlhttp.send();
}
</script>
They are both being sent asynchronously, so in theory should work.
Can someone help me spot the problem here?