I am trying to populate an array (for use with jquery-ui element) using an Ajax request which I am not very familiar with. There are two files, selectStudents.php which is what will be viewed and loadStudents.php which is what the Ajax requests.
When I view loadStudents.php, copy the output, and replace the Ajax request with that instead it works perfect, so I am simply doing something wrong with my ajax. Anyone see off hand what it is?
<script>
$(function() {
var availableTags = new Array();
new Ajax.Request('includes/loadStudents.php', {
onSuccess : function(xmlHTTP){
eval(mlHTTP.responseText);
}
});
$( "#tags" ).autocomplete({
source: availableTags
});
});
</script>
Thanks!
That looks like prototype. If you’re using jQuery, an ajax request looks like this:
See
jQuery.ajaxfor more details.Additionally using jQuery UI you can let autocomplete handle the ajax for you:
See jQuery UI Autocomplete for further usage.