Reputation: 3898
I am very new to jQuery and javascript. I have an autocomplete box setup (from jQuery UI). After the user selects his value from the search box, how do I pass that value to another php page (ie getmatches.php, which will look up that value in our database). I have:
$(function(){
$("#my_cell").autocomplete({
source: "autocomplete.php",
minLength: 1,
delay: 0,
select: function (event, ui) {
// what goes here?
}
});
});
Upvotes: 1
Views: 159
Reputation: 5997
jQuery Autocomplete by default is passing the value of the input to the source you've specified through GET parameter called term
. So if you type for example world it will do a request to autocomplete.php?term=world
I highly do not recommend to do AJAX requests inside the SELECT event handler function. Unless you mean something else (like tracking that).
Upvotes: 0
Reputation: 1312
you can either attach a get param to url like this:
source: "autocomplete.php?param_name=" + document.getElementById("myfield").value,
but I think the $.autocomplete plugin function may provide API for sending parameters to backend, I think you should read documentation for it, in most cases docs specify everything you need
Upvotes: 1
Reputation: 840
You can use GET parameters like so:
http://yourserver/getmatches.php?search=<yoursearchstring>
In getmatches.php, retrieve the variable.
Upvotes: 0