Hey everyone. Got a problem that I really need help solving.
I have a page where a user is able to search a database for certain criteria (species/location/dates etc). What I have so far is when the form is submitted, the values are posted to a PHP script, which performs a MySQL query and then returns the result in json_encode(). What I want to happen is:
- User fills form
- User clicks submit
- Input values held in JavaScript
- JavaScript calls the PHP script that peforms the query and returns result as JSON
- JavaScript gets JSON response, and iterates through placing markers on a Google Map.
Now I have all the key features here, but combining them together is causing me a headache, and I know that AJAX is my solution. Here's my HTML that calls the JS.
<form id="form" name="form" method="post" onclick="getQuery()">
The JS getQuery():
function getQuery(){
$.ajax({
type: "GET",
url: 'userquery.php',
data: "",
complete: function(data){
var test = jQuery.parseJSON(data);
alert(test.names[0]);
alert("here");
}
},
"json");
}
getList();
Obviously this needs work in order to produce the results I desire, but at the moment I'm just trying have the response available for handling.
Any help pleeease?