Feeding variable to AJAX call
Hi everyone,
I'd appreciate your help on the following.
I have a JQuery script which makes an AJAX call. When I feed the datastring as 'web' (an actual string value), it works (the php script in the AJAX call returns all jobs starting with 'web%' from the database).
But it's not working when feeding the ID's value of the inputfield (preferrably while typing in the inputfield). What am I doing wrong?
Thank you in advance for any help,
Onkelarie
Code:
<script>
$(document).ready(function () {
'use strict';
$.ajax({
url: 'assets/ajax/icares_lookup.php',
dataType: 'json',
cache: false,
data: { datastring: $('#autocomplete_icares').val() }
}).done(function (data) {
var status = $('#selection'),
professions = $.map(data, function (value) {
return value;
});
$('#autocomplete_icares').autocomplete({
lookup: professions,
onSelect: function (suggestion) {
//status.html('You selected: ' + suggestion);
}
});
});
});
</script>
<div class="form-input">
<input type="text" name="icares_career_goal" id="autocomplete_icares">
<div id="selection"></div>
</div>