3 Replies - 5009 Views - Last Post: 13 March 2010 - 10:53 AM

#1 kinged007  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 35
  • Joined: 05-November 09

AJAX not working the 2nd time?

Posted 03 February 2010 - 06:48 AM

Hi,

I saw this topic on jQuery docs once before, but didnt read it properly, now im having the same problem and cant find the solution again. :(

I have my first page which loads a second page into a div through a $.ajax() call. that works fine.
The second page that gets loaded has a form and submits it via ajax. But the form does not send, no result is returned, nothing. zippo....
When i open the second (form) page directly, and submit the form. the form is handled through ajax no problem.

I thought i may had to include the $.ajaxStop() function, but that doesnt seem to work.

Any ideas? Has this been answered already?

Thanx

Is This A Good Question/Topic? 0
  • +

Replies To: AJAX not working the 2nd time?

#2 kinged007  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 35
  • Joined: 05-November 09

Re: AJAX not working the 2nd time?

Posted 04 February 2010 - 02:57 PM

still stuck? :(
Was This Post Helpful? 0
  • +
  • -

#3 Zichlone  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 16
  • Joined: 13-August 08

Re: AJAX not working the 2nd time?

Posted 20 February 2010 - 09:30 AM

Can you post the code for both the pages?
Was This Post Helpful? 0
  • +
  • -

#4 moopet  Icon User is offline

  • binary decision maker
  • member icon

Reputation: 339
  • View blog
  • Posts: 1,185
  • Joined: 02-April 09

Re: AJAX not working the 2nd time?

Posted 13 March 2010 - 10:53 AM

View Postkinged007, on 03 February 2010 - 12:48 PM, said:

Hi,

I saw this topic on jQuery docs once before, but didnt read it properly, now im having the same problem and cant find the solution again. :(

I have my first page which loads a second page into a div through a $.ajax() call. that works fine.
The second page that gets loaded has a form and submits it via ajax. But the form does not send, no result is returned, nothing. zippo....
When i open the second (form) page directly, and submit the form. the form is handled through ajax no problem.

I thought i may had to include the $.ajaxStop() function, but that doesnt seem to work.

Any ideas? Has this been answered already?

Thanx


I would imagine what is happening is that you have something bound to the form submit like
$('form#whatever').submit(function() {
// do ajax form submission here
});


in a script loaded on the main page. This is a trap. The binding doesn't automatically bind to content added to the page later (like your form)
With the latest jQuery, you can do something like this:
$('form#whatever input[type="submit"]').live('click', function() {
// do ajax form submission here
});



If that's the problem, read up on the "live" method in the jQuery docs (or ask for more help here) if you don't get it.
If that's not the problem, well, let's see the code!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1