My JavaScript is not working after ajax response i know that i have to use $('.ajax-link').on('click', 'a', function (e){
function for it but when i am using this mye.preventDefault();
is not working (means whole page is loading instead of ajax call) and if i am using $('a.ajax-link').click(function (e) {
then ajax is working fine but all script of ajax response page is not working after ajax response . i am using jquery 1.10
. below is my whole code :
$('a.ajax-link').click(function (e) {
NProgress.start();
if (msie) e.which = 1;
if (e.which != 1 || !$('#is-ajax').prop('checked') || $(this).parent().hasClass('active')) return;
e.preventDefault();
$('.sidebar-nav').removeClass('active');
$('.navbar-toggle').removeClass('active');
$('#loading').remove();
$('#dvLoading').show();
var $clink = $(this);
History.pushState(null, null, $clink.attr('href'));
$('ul li.active').removeClass('active');
$clink.parent('li').addClass('active');
});
History.Adapter.bind(window, 'statechange', function () { // Note: We are using statechange instead of popstate
var State = History.getState(); // Note: We are using History.getState() instead of event.state
$.ajax({
url: State.url,
success: function (msg) {
$('#dvLoading').fadeOut(10);
NProgress.inc();
$('.main-sec').html($(msg).find('.main-sec').html());
NProgress.inc();
setTimeout(function() { NProgress.done(); $('.fade').removeClass('out'); }, 100);
$('#loading').remove();
$('.main-sec').fadeIn();
var newTitle = $(msg).filter('title').text();
$('title').text(newTitle);
docReady();
}
});
});