After Ajax Call jQuery function not working properly
X

Congrats, You are Subscribed to Receive Updates.

After Ajax Call jQuery function not working properly


After Ajax Call jQuery function not working properly. Sometime after the after the Ajax call the popular jQuery plugins and jQuery custom functions stop responding. Its one of a biggest hassle when you rewriting contents after Ajax call. Here the problem is nothing, actually when the DOM gets ready all the event were loaded.

Than after the ajax call the elements are redrawn again. So the events are already there in DOM. But the newly drawn content is not inherited the events. Especially the jQuery events such as hover, click, and all the JavaScript events and jQuery events also. So there must be a solution for the issue, here we have to use jQuery delegate function.

Let’s start writing our each functions with delegated jQuery functions.

$(document).on('click', "#elementID" , function () {
   //your operations here...
});

That’s it. And when you write jQuery functions always write it delegate, it will work definitely.

And for the jQuery plugins, just use the following functions.

function recallfunctions() {
    $("#datepicker").datepicker();
}

Just call the above function again after the Ajax return. After the elements recreated.
This will help you to solve it.

commenter

About Varadharaj V

The founder of Kvcodes, Varadharaj V is an ERP Analyst and a Web developer specializing in WordPress(WP), WP Theme development, WP Plugin development, Frontaccounting(FA), Sales, Purchases, Inventory, Ledgers, Payroll & HRM, CRM, FA Core Customization, OpenCart Theme Development, PHP, HTML, CSS, jQuery, Bootstrap development and content SEO.

Comment Below

Your email address will not be published. Required fields are marked *

*

Current ye@r *

Menu

Sidebar

Subscribe E-mail Updates

Congrats, You are Subscribed to Receive Updates.

Advertisement

Category Posts