executing script after jQuery Ajax Call
Probably you should use jQuery.getScript to loading some javascript from the server and execute it.
UPDATED:
In the most cases one load only the pure HTML fragment with respect of jQuery.ajax
. Binding of elements to some javascript functions one do inside of success
handle. All functions which one use in any event handler one loaded before (with <script>
in the <head>
block) on the main page (on the page which call jQuery.ajax
). Then all look very clear and dynamic loading of any scripts is not needed.
waterschaats
Updated on June 04, 2022Comments
-
waterschaats almost 2 years
I load some HTML code into a div with the .load function af jQuery that contains some code I want to execute;
$.ajax({ type: "GET", url: url, dataType: "html", success: function(data){ //..... } });
After loading the ajax request the alert(); function works, but the the someFunction won't.
$(document).ready(function(){ alert('TEST'); //this works someFunction("#debug",'var');//this doesn't });
How can I execute this function from an Ajax call
A function executed as
<a onclick="someFunction()"
won't work either.