In Ajax calls that contains script tag, all sent scripts will execute after insert to document object model.
But in your case, script tag contains event assignment so event assignment will execute, but why assigned function execute after insert to document object model while ready event don't raised? the reason of this happening it is:
summary :
Ready only similar to event but is not really one event, it is Pseudo-Event.
Detailed
Follow code is source of jquery library:
jQuery.fn.ready = function( fn ) { // Add the callback jQuery.ready.promise().done( fn ); return this; };
you see that ready is a jQuery plugin that get a function. In the body of function said when ready event is done execute sent function.But when ready is done.see JQuery source again:
jQuery.extend( { // Is the DOM ready to be used? Set to true once it occurs. isReady: false, // A counter to track how many items to wait for before // the ready event fires. See #6781 readyWait: 1, // Hold (or release) the ready event holdReady: function( hold ) { if ( hold ) { jQuery.readyWait++; } else { jQuery.ready( true ); } }, // Handle when the DOM is ready ready: function( wait ) { // Abort if there are pending holds or we're already ready if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { return; } // Remember that the DOM is ready jQuery.isReady = true; // If a normal DOM Ready event fired, decrement, and wait if need be if ( wait !== true && --jQuery.readyWait > 0 ) { return; } // If there are functions bound, to execute readyList.resolveWith( document, [ jQuery ] ); } } );
The following line set that load document object model is done :
// Remember that the DOM is ready jQuery.isReady = true;
so if Jquery.isReady == true, function that passed to ready method immediately execute.
so ready method is provided for scripts which run in ready state not ready event.