You create a new div and set its text, but you don’t insert it anywhere. What you need to do is:
var el = $('<div id="error">').text('Test message here');
$(document).append(el);
or, if the div is already there:
$("#error").text('Test message here');