I finally figured it out! The input was in a form, so the implicit
form submit was apparently interfering with the AJAX callback.

This doesn't work:

<form id="subscriptionForm" action="" method="post">
  <input type="image" id="btn_recipient_search" src="/IdeaStore/images/
btn_search.gif" alt="Search" />
  ...
</form>

This does:

<form id="subscriptionForm" action="" method="post">
  <a href="#" id="btn_recipient_search"><img src="/IdeaStore/images/
btn_search.gif" alt="Search" /></a>
  ...
</form>

John

On Sep 4, 11:23 pm, Jack Killpatrick <[EMAIL PROTECTED]> wrote:
> Sounds like you might having a caching issue. Try these:
>
> once:
>
> $.ajaxSetup({cache:false}); // global setting to prevent caching
>
> then do your $.get's as you have them. Or:
>
> append a timestamp to your get url:
>
> $.get("recipients.xml?" + new Date().valueOf().toString(),
>
> - Jack
>
> JDawson wrote:
> > 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