Reputation: 1773
My problem doesn't concern Ajax purposes, but javascript initialisations.
When we use $(element).load(...)
, how could I automatically update all the loaded elements to create - for example - a rangeInput element from a input type text ?
What I'm searching is a trigger like $(button).onClik()
for load()
and post()
functions.
Upvotes: 0
Views: 48
Reputation: 176886
you can try like this by using jQuery load() function.
$( element).load( "ajax/test.html", function() {
alert( "Load was performed." );
});
for each load you can create common function and call it
$( element).load( "ajax/test.html",
commonfunction
);
var commonfunction = function ( response, status, xhr ) {
if ( status == "error" ) {
var msg = "Sorry but there was an error: ";
$( "#error" ).html( msg + xhr.status + " " + xhr.statusText );
}
}
Upvotes: 0
Reputation: 74420
You could use global ajax event as ajaxComplete():
$( document ).ajaxComplete(function( event, xhr, settings ) {
console.log(xhr.responseText);
});
Upvotes: 2