I have two jQuery UI Autocomplete widgets set up. With the first autocomplete, the user will enter a client's name - the autocomplete will narrow it down until the correct client has been chosen. I then have a callback that takes the ID of the client returned and puts it into a hidden input field.
Next, is a second autocomplete field. When searched in, this needs to send two variables to the server - the user's search string (term), and the User ID of the client that was searched for previously.
I have no problems dealing with the server side of things, but where I'm struggling is how to pass 2 variables to the Ajax call, rather than just term. In my PHP backend, I need to query against the User ID as well, to only return properties belonging to that user.
How can I do this?
Thanks!
Edit: Thanks to @JohnP, this was what I ended up - seems to work fine for me. Posting this here for reference for anyone in future who drops by:
source: function (request, response) {
var request_data = {
term: request.term,
client_id: $('input#client_id_string').val()
};
var url = 'http://mysite.com/search/ajax_search';
$.getJSON(url, request_data, function (data, status, xhr) {
response(data);
});
},