I use ajax to load a page (example.html). I’ve got two buttons: one for ajax load function and another to act on loaded content. But it doesn’t react. I tried to use:
$(document).ready(function(){
$("#load")
.click(function(){
$("content").load("example.html");
});
$("#example_content").load(function(){
// some actions to loaded page
});
the jQuery load function does not work like and event hook function, so the second .load call will expect to receive a url-like string to make a new request to the server to get more data (link http://api.jquery.com/load/).
If you want to do something with the content that was loaded into the div, I’d suggest you use the ajax method, which could be used like this:
If you want to shorter way, using the $.get(url, success) function should help you, but this uses $.ajax inside, so you’re better off using directly $.ajax.
Recap:
1) .load is a function that uses .get to fetch content. http://api.jquery.com/load/
2) .get has a success function, which writes the content received from the given url to the target element. http://api.jquery.com/jQuery.get/
3) .get is a function .ajax, which is the core of the jQuery ajax functionality. http://api.jquery.com/jQuery.ajax/