Actually, this will be called three times. One before the ajax request is sent, one after the ajax response is arrived and one when the ajax response is successfully processed. You need to check the current status based on the provided data argument. You can find technical details in tables 14-4 and 14-3 of the JSF 2.0 specification.
Here's a kickoff example of how your JS function should look like when you'd like to hook on all 3 of the statuses.
function ajaxUpdate(data) {
var ajaxStatus = data.status; // Can be 'begin', 'complete' and 'success'.
switch (ajaxStatus) {
case 'begin': // This is called right before ajax request is been sent.
// ...
break;
case 'complete': // This is called right after ajax response is received.
// ...
break;
case 'success': // This is called when ajax response is successfully processed.
// ...
break;
}
}
Or when you'd like to hook on the success status only:
function ajaxUpdate(data) {
if (data.status == 'success') {
// ...
}
}