I created a php that returns JSON to my autocomplete. example: [{"value":"david schuun","id":"120"}]
Now I want to extend the autocomplete function to pass by additional parameters to this php.
$( "#REMOTE" ).autocomplete({
source: "json.php",
minLength: 2,
extraParams: {aus: 'eins'} , // this should work like "www.bla.de/json.php?aus=eins " but it doesn't
select: function( event, ui ) {
log(ui.item.value,ui.item.id);
}
});
Testing this via URL works fine. The PHP script is ok. But I don't know why the Jquery thing doesn't work.
Ok, here is the whole script:
<script>
$(document).ready(
function() {
//this functions reads every hidden field (form the added items) an puts the array as string to a hidden field
function lesen(){
var itemsarray = [];
$(".nutzerid").each(function () {
var items = $(this).attr('value');
itemsarray.push(items);
});
$( "#ausschluss" ).val(itemsarray);
};
//this function attaches the selection (from the autocomplete) to a table it creates text, a hidden field with the user id and a button
function log( name, id ) {
$("<tr> <td>" + name + "<input class='Entf' type='button' value ='Entfernen' />" + "<input type='hidden' class='nutzerid' name='hiddenField' value='" + id + "' /></td></tr>").appendTo("#log");
$( "#log" ).attr( "scrollTop", 0 );
lesen();
}
//this is the autocompletepart
$( "#REMOTE" ).autocomplete({
source: "json.php?aus=" + $( "#ausschluss" ).val(), //this is not working. the firebug console shows an empty param (.php?aus=&term=blabla
minLength: 2,
select: function( event, ui ) {
log(ui.item.value,ui.item.id);
alert($( "#ausschluss" ).val()); //this works! after selecting an item from the autocomplete it shows me the value of the field "ausschluss", like it should be appended to the source
}
});
//this one captures the click of a button. identified by the class and kills the <tr> <td> and all elemtns in it
$('.Entf').live('click',function(event){
$(this).parent().parent().remove();
lesen();
});
});
</script>
Any hints? I realy don't know, why it works with alert, but not with attahcing to the source.
I'm realy confused about this problem. I'm not a JS pro. But I can't understand why this thing doent't work!!!!!!!