UPDATING mySQL db with AjAX
Posted: Tue Nov 11, 2008 4:24 am
Can I use the code listed below to send information to a script on my server so that I can use it to update a database?
To be honest I hacked this together from several different sites and I am not sure how to test it
I ran a few echos if the values landed on the server file but that won't work because I am not viewing
the file in browser.
Thank You
Kevin Raleigh
Code: Select all
function createRequestObject(){
var ajaxRequest = false;
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
return false;
}
}
}
}
function loadPatient (){
var volunteerMemberId = form.volunteerMemberId;
var patientMemberId = form.memberId;
var http = createRequestObject();
http.open('get','loadPatient.php?<php?memberId=volunteerMemberId&patientId=patientMemberId ?>');
http.send(null);
}
</script>
<a href='findPatient.php' onclick='loadPatient();'>Select Patient</a>
I ran a few echos if the values landed on the server file but that won't work because I am not viewing
the file in browser.
Thank You
Kevin Raleigh