I am trying to use .get in a click handler to load some XML, as shown
below. The handler will only work if I first call my getRecipients
function in $(document).ready. I am really pulling my hair out with
this. I can see in my Firebug console that the file request is being
made via the click event, but it just flashes in the console and
nothing else happens.

Any help is greatly appreciated.

Thanks,
John

  <input type="image" id="btn_recipient_search" src="btn_search.gif"
alt="Search" />

  $("#btn_recipient_search").click(
    function() {
      getRecipients("John", "Doe");
    }
  );

  function getRecipients(firstName, lastName) {
    $.get("recipients.xml", {fName: firstName, lName: lastName},
function(xml){
      alert('XML loaded');
      $(xml).find('User').each(function() {
        var name_text = $(this).find('Name').text();
        var id_text = $(this).find('UserId').text();
        var email_text = $(this).find('Email').text();
        alert(name_text);
      });
    });
  }

Reply via email to