title: reference my XML in a function using 'this'
body: <p>I have the following script to look up an XML file and produce an ordered list. The result is displayed in a div box and each item in the list can be selected by the user. When an item in the list is clicked, the function '<strong>selected()</strong>' will be called. </p>
  
  <p>This all works fine, I can list the data and the user can select. The problem is that I want to populate a form with the XML results and need to reference the selected items , I thought that I could use <code>this</code> but I am getting errors. Can anyone offer some advice please? </p>
  
  <p>I have omitted some of the code that displays the div boxes etc.</p>
  
  <pre class="lang-javascript prettyprint-override"><code>function searchaddress() {
      searchstring = $('#nam').val();
      chr = searchstring.length;
  
      $(document).ready(function() {
          $.ajax({ type: "GET",
                   url: "../241/NEWsearch_action.php?ss=" + searchstring ,
                   dataType: "xml",
                   success: searchxml });
      });
  } 
  
  // data returned from AJAX.php 
  function searchxml(data) {
      var display = "";
      var msg = "";
      var currentWidth = 25;
  
      $(data).find('NameSearch').each(function() {
          numres = $(data).find('NameSearch').length;
          coursename = $(this).find('sitelist').text();
          address1 = $(this).find('address1').text();
          address2 = $(this).find('address2').text();
          postcode = $(this).find('postcode').text();
          number1 = $(this).find('number1').text();
  
          string = "&lt;b&gt; &lt;a onclick='selected(" + **this** + ")' &gt; " + coursename &lt; /br&gt; " ; 
          msg += string;
      }); // find loop
      $('#UniDivBody').html(msg);
  }
  
  function selected(e) {
      coursename = $(e).find('sitelist').text();
      // REFERENCE THE SELECTED DATA HERE???
  }
  </code></pre>