I am making a JSP Application that calls Ajax request to the Servlet. I had taken reference from How to use servlets and Ajax.
I am facing a problem in adding responseText
as innerHTML
of my div. I tried
$('#testdiv').html(responseText);
but it is displaying it as text instead of as HTML.
My Code is:-----------------
function getdata(){
var mobile = document.loyaltyForm.mobile.value;
var code = document.loyaltyForm.mobilecode.value;
var response = '';
var testdiv = document.getElementById("testdiv");
// Locate HTML DOM element with ID "somebutton" and assign the following function to its "click" event...
$.post('loyal', {mob:mobile,mobilecode:code}, function(responseText) { // Execute Ajax GET request on URL of "someservlet" and execute the following function with Ajax response text...
alert('Response:'+responseText);
});
}