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!
$()style, but theAjaxcall looks like another library. What libraries are you using?Ajax.Requestfrom? What isxmlHTTP.responseText? Why do youevalit? The problem is most likely a very common one: TheonSuccesscallback is executed after the$( "#tags" ).autocomplete(...)call. Ajax is asynchronous. Only access the data you get as response inside the callback.Ajax.Requestis not jQuery. And given that jQuery provides good Ajax functionalities, the question is why use another library.