I've had this problem before but never found a solution, so here's goes..
I have some pages that are loaded via ajax... basically, a page is being loaded into a div. I want the content within that div (or the remote page) to use jQuery. the document.ready does not work, neither do any other functions.
Any idea how to do this?
Also to note, I have jQuery being included in both the remote page and the parent.
Thanks!
jQuery not working on ajax pages
Moderator: General Moderators
- lukewilkins
- Forum Commoner
- Posts: 55
- Joined: Tue Aug 12, 2008 2:42 pm
Re: jQuery not working on ajax pages
I personally prefer Prototype: http://www.prototypejs.org/
BUT, jQuery will work the same way in which once a div is loaded with content (via Ajax) it is "part" of the parent page. Meaning, it can access all of the functions present on that page including those part of jQuery.
If you don't understand what I'm saying, leave your code here and I'll take a look at it for you.
Luke
BUT, jQuery will work the same way in which once a div is loaded with content (via Ajax) it is "part" of the parent page. Meaning, it can access all of the functions present on that page including those part of jQuery.
If you don't understand what I'm saying, leave your code here and I'll take a look at it for you.
Luke
Re: jQuery not working on ajax pages
Ahhh.. I see... However, it still doesn't seem to work.. I must be doing something wrong..
Here's snippets of the code
Main Index (Parent)
Ajax Page being loaded into <div id="content"></div> from parent.
I put this in as a test and it didn't work...
Here's snippets of the code
Main Index (Parent)
Code: Select all
$(document).ready(function(){
$('#delete').click(function(){
alert('test');
});
});
Code: Select all
<a href="#" id="delete">delete</a>
Re: jQuery not working on ajax pages
I got it.. I was calling it before the ajax was executed... Thanks so much!!! Seems very simple, but literally spent hours trying to figure it out.. thanks!
- lukewilkins
- Forum Commoner
- Posts: 55
- Joined: Tue Aug 12, 2008 2:42 pm
Re: jQuery not working on ajax pages
No problem. Glad it is working for you!
Luke
Luke