How would i retreive multiple (GET) values from a php file using AJAX…
Say i had the following function that ask’s for a userID variable - how could i ask for more than one variable instead of just userID? so i can change the html with:
ajaxDisplay1.innerHTML = ajaxRequest.responseText;
ajaxDisplay2.innerHTML = ajaxRequest.responseText;
ajaxRequest.onreadystatechange = function() {
if(ajaxRequest.readyState == 4) {
var ajaxDisplay = document.getElementById("tagButton");
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
var userID = 1581813101;
var queryString = "?userID="+userID;
ajaxRequest.open("GET", "test.php" + queryString, true);
ajaxRequest.send(null);
}
And here’s the test.php file code
<?php
include('db.php');
$userID = $_GET['userID'];
$query = "SELECT firstName, lastName FROM user_details WHERE profileID = $userID";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
$userID = $row[firstName];
echo $userID;
?>