F: ajax and jquery `$ (document) .ajaxStart` do not work together?

I am trying to get a “loading” div for my ajaxified site. using the JSF 2.0 tag f:ajaxto add ajax to the site and "try" to make displayin divusing the function jQuery $(document).ajaxStart.

Part of jQuery code is as follows:

$(document).ajaxStart(function(){
    console.log("ajax start");
  $('#ajaxBusy').show(); 
}).ajaxStop(function(){
    console.log("ajax end");
  $('#ajaxBusy').hide();
});

Log functions are never called. Any idea why? Does JAF ajax and javascript ajax work?

Thank!

+3
source share
3 answers

You can use jsf.ajax.addOnEvent(callback)to display the boot div. Maybe so addOnErrortoo.

See documentation

jsf.ajax.addOnEvent(statusUpdate);
...
var statusUpdate = function statusUpdate(data) {
...
}

You will need to work with data.status

  • begin: before sending the request
  • complete: received request
  • success: ( )

api:

+5

$ jsf, jquery.

jQuery :

jQuery(document).ajaxStart(function(){ ... });
+1

. JSF AJAX-, jQuery ajaxStart/ajaxStop , AJAX jQuery $.ajax.

, Primefaces, jQuery ajaxStart/ajaxStop, jsf.ajax.onEvent .

+1

All Articles