jQuery UI Autocomplete extraParams Problem
I have a jQuery autocomplete application where the user types a query into a text box and autocomplete suggestions are returned. (It's working fine.) I would like to restrict the suggestions that are returned by passing the value of the selected option from a drop-down list (#deptField3) to the PHP script that does the autocomplete look-up.
Here is my code:
- <script type="text/javascript">
- <!--
- $(function() {
- $("#directorySearchField-desktop").autocomplete({
- source: "/directory/includes/scripts/autocomplete.php",
- extraParams: {
- dept: function() { return $("#deptField3").val(); }
- },
- minLength: 2,
- delay: 0,
- select: function(event, ui) {
- $('#LN').val(ui.item.LN);
- $("#searchForm").submit();
- }
- });
- });
- -->
- </script>
When I look at the URL (get request) that is being passed off to the PHP autocomplete script, it is correctly appending my search term in the URL as follows:
MY-SITE/autocomplete.php?term=MySearchTerm
... but the additional parameter "dept" (which is set in line #8 in the code above) is not being appended to the autocomplete URL.
In other words, if it were working properly, the URL should look like this:
MY-SITE/autocomplete.php?term=MySearchTerm&dept=SelectedDeptValue
Thanks in advance for any insight/assistance that you may be able to offer.
- John