title: jQuery-ui / auto-complete / getJSON - How to pass the id of the element to the external PHP
body: <p>I'm binding the jQuery-ui autocomplete to more than one element in my page as I want to have autocomplete with the same set of options in different fields. Something like:</p>
  
  <pre><code>&lt;input class='myclass' id='myid1' name='field1' type='text' /&gt;
  &lt;input class='myclass' id='myid2' name='field2' type='text' /&gt;
  &lt;input class='myclass' id='myid3' name='field3' type='text' /&gt;
  </code></pre>
  
  <p>I'm using the "Multiple Remote" option from jquery-ui autocomplete, so the javascript looks something like this:</p>
  
  <pre><code>$(".myclass")
      // don't navigate away from the field on tab when selecting an item
          // don't navigate away from the field on tab when selecting an item
          .bind( "keydown", function(event) {
              if (event.keyCode === $.ui.keyCode.TAB &amp;&amp;
                  $(this).data("autocomplete").menu.active) {
                  event.preventDefault();
              }
          })
          .autocomplete({
              source: function( request, response ) {
                  $.getJSON("search.php"
                           ,{ term:extractLast(request.term) }
                           ,response);
              },
              search: function() {
                  // custom minLength
                  var term = extractLast(this.value);
                  if (term.length &lt; 1) {
                      return false;
                  }
              },
              focus: function() {
                  // prevent value inserted on focus
                  return false;
              },
              select: function( event, ui ) {
                  var terms = split( this.value );
                  // remove the current input
                  terms.pop();
                  // add the selected item
                  terms.push(ui.item.value);
                  // add placeholder to get the comma-and-space at the end
                  terms.push("");
                  this.value = terms.join(", ");
                  return false;
              }
          });
  </code></pre>
  
  <p>It all works very nice. 
  But I want to pass the id as a second parameter to getJSON. How can I accomplish this? </p>
  
  <p>I know how to add a second parameter to the <strong>$.getJSON</strong> statement, but I'm not being able to grab the <strong>"id"</strong> of the event trigger. I tried <strong>$(this).attr('id')</strong> but it gave me <em>undefined</em>. Any suggestions?</p>
  
  <p>Thanks.</p>