Actually, it will be called three times. One before sending the ajax request, one after the ajax response, and one when the ajax response is successfully processed. You should check the current status based on the data argument. You can find technical details in tables 14-4 and 14-3 of the JSF 2.0 specification .
Here is an example of launching what your JS function should look like when you want to connect all 3 states.
function ajaxUpdate(data) {
var ajaxStatus = data.status;
switch (ajaxStatus) {
case 'begin':
break;
case 'complete':
break;
case 'success':
break;
}
}
Or if you want to connect only to the status success:
function ajaxUpdate(data) {
if (data.status == 'success') {
}
}
source
share