There are 2 approaches to managing code for newly inserted html such as when using load()
. Either you have to run any event binding code ( or plugins) on the new elements after they are inserted , or you have to use event delgation that binds to elements further up the DOM tree that are permament assets in the page
Delegation approach ( accounts for future or replaced elements):
Instead of $('.myButtonclass').click....
use:
$(document).on('click', '.myButtonclass', function(){
/* same code you already have in current click handler*/
})
After insertion approach:
$('#content').load('path/to/server', function(){
/* new html exist now*/
$(this).find('.buttonClass').click....
})
FYI- jsonp
is used for retrieving JSON data cross domain... is very different than html. Subject of this thread got confusing due to reference to jsonp