Phpworker
answered Apr 28 '23 00:00
Here's a possible rewrite of the previous answer to avoid duplicate content:
To execute a function after an AJAX load, you can use the .load() method in jQuery:
<div id="myDiv">
</div>
<button id="myButton">Load Content</button>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$('#myButton').click(function() {
$('#myDiv').load('/path/to/content', function() {
yourFunction();
});
});
function yourFunction() {
console.log('Content loaded via AJAX');
}
</script>
In this example, the . load () method is used to load content from the server into the #myDiv element when the #myButton button is clicked. The second argument to the .load() method is a function that will be called after the AJAX content is loaded.
You can customize the yourFunction () to execute any actions that you want to take after the AJAX content has been loaded.