I am currently translating my ajax calls for a regular call to $.pjax() . Everything works fine, but the success function is ajax. I cannot control how to call the pjax success function with the given parameters.
The only thing I can use is to define the pjax global success function that will be called every time pjax is called:
$(document).on('pjax:success', function(event, data, status, xhr, options) { });
But, unfortunately, I would like to define a specific success function for each call.
Ajax call example:
$.ajax({ url:"/myPage/myFunction", type:"POST", data:giveMeData(), success:function(data){$('#right_form').html(data);console.log('Success works!')} });
Pjax call example:
$.pjax({ url:"/myPage/myFunction", type:"POST", container:'#right_form', data:giveMeData(), success:function(){console.log('Success works!')} });
javascript jquery ajax pjax
user2133627
source share