In your example,
$("ul").html("");
can be replaced with $("ul").empty();
The replacePlaceholdersInMessage function uses replace with string as the match, which means that in rare cases where more than one %F is present, for instance, only the first will be replaced. To fix this you have to pass in a new RegExp object with the 'g' (global) flag instead. See https://developer.mozilla.org/en-US/docs/JavaScript/Referenc...