This should straightforward but I have no idea what is wrong.
I am making an ajax call when there is onblur event on a text field. Ajax request goes to backend and gets the response. Then I have to append that response next to the text field. But it's not working.
HTML
<input type="text" required="" id="123456" onblur="validateWithDB(this)"></input>
Javascript
function validateWithDB(field)
{
$.ajax({
type:"POST",
url:"validate",
data: "fieldValue="+field.value,
success: function(response) {
alert(response);// this is correct
alert($(field).val());// this is correct
var result = '<span class="help-inline">'+response+'</span>'
alert(result) // this is correct
$(field).html(result);// Does not show up.
},
error:function (xhRequest, ErrorText, thrownError) {
alert('Error: ' + ' ' + xhRequest);
}
});
}
I tried both $(field).html(result); and $(field).append(result); but no luck.