jQuery ajax

Hi Guys!

I’m trying to get jQuery to send values to a PHP script using Ajax. Here’s the code I have so far, but it doesn’t seem to alert me with any data. I know the PHP scripts works, so just need to get this part working. Any ideas?

<script>
$(document).ready(function() {
	$("#location_ajax").keydown(function(event){
		$.get("ajax/locations.php", { input: "chigwell" },function(data){ alert("Data Loaded: " + data); });
	});
});
</script>

It might be easier to debug it if you ditch the jquery. Not sure why you want to do this using jquery when you can most likely do it with less code using plain javascript.

You could just create an ajax object and then use its responseText property to monitor what is going on in your php script and to check what it is returning. Using just plain javascript, when the data is loaded in the server you would send back a message like “success” via the responseText after which the alert() can be fired in the onreadystatechange handler.

Your code works for me, so there’s something else that’s going wrong.

If you provide a link to a test page that demonstrates the problem, we can use development tools to find out exactly where the problem is occurring, and get closer to a viable solution for you.