I am currently trying to use AJAX to retrieve selected records from DB. I have 2 files - browser.php and getrecord.php.
In browser.php, I use geolocation javascript to get latitude and longitude and store them in global variables:
browser.php
var numlat;//store latitude
var numlong;//store longitude
function loadrecord(numlat,numlong)
{
if(numlat=="" || numlong==""){
document.getElementById("box").innerHTML="";
return;
}
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("box").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getrecord.php?q=numlat&r=numlong", true);
xmlhttp.send();
}
My main question is how do I sent a request to the server for getrecord.php using numlat and numlong as the 2 parameters? I will need to use them var numlat and var numlong values to do a SELECT in my database and display them in browser.php.
getrecord.php
$q = $_GET['q'];//i am trying to get the latitude
$r = $_GET['r'];//i am trying to get the longitude
//i will need to use $q and $r to do a SELECT in my database.
Sorry, if this is a noob question.