I have a problem with tow jquery function, I have a autocomplete search box on form and tow function in script part. I want a function fetch a list and other one autocomplete text box but can`t call fetch function at first. It run after autocomplete function all the time.Can every one help me?
1- fetch list function is:
$(function ()
{
$.ajax({
url: 'fetch_user_list_from_user_table.php',
data: "{}",
dataType: 'text',
success: function(data)
{
user_list=data;
alert("list is: " + user_list);
},
error: function()
{
$('#output').html("Error");
}
});
});
2- autocomplete function
$(function ()
{
var availableTags;
availableTags =user_list;
alert("tags are"+availableTags);
$( "#tags" ).autocomplete(
{
source: availableTags
});
});
3- html part
<input id="tags" type="text" name="message_receiver_title"> </input>