I have a page(parent.php) from where i am calling a another page(result.php) through jquery ajax that is returning a response in html format. This response is showed on the parent.php page in a div. How can i secure my ajax response from xss attack. Here is the code snippet of parent.php page
$.ajax({
type: "POST",
url: "getResult.php",
data:{search_in:search_in},
beforeSend:function(){
$("#search_result").html('Loading..');
},
success: function(result)
{
$("#search_result").html(result);
$("#search_result").show();
}
});
in the getResult.php page i am quering database based on the parameter and returning some result in html form like table. How can i prevent cross site attack
$("#search_result").text(result);
would be immune