daveycroqet
daveycroqet

Reputation: 2727

JavaScript Inside AJAX to Request More AJAX

I built a rudimentary page navigation system with jQuery. You click the next button, it retrieves the next page via AJAX; click the previous, it goes to the one before it, etc. The AJAX request is done via the jQuery $('#dom').html().load() method.

Inside one of the pages pulled is an a href link with an onclick which goes to a custom function (loadPage() -- the same function I'm using for the parent page navigation). As you can guess, the onclick event used inside the AJAX page does not work -- it's trying to call a function that doesn't exist.

Is there a simple way to make this work? Perhaps some other jQuery AJAX method like GET? Thanks in advance.

Upvotes: 1

Views: 118

Answers (1)

Andy Gaskell
Andy Gaskell

Reputation: 31761

It sounds like you are embedding JavaScript into your html. Don't do that. Put your JavaScript into an external file and include it with a script tag, just like you do with jQuery.

Upvotes: 3

Related Questions