Change div backgroung color base on result from servlet using jquery
- by Both FM
Java Script Code Snippet
$(document).ready(function() {
$("#button").click(function(){
$cityName = document.getElementById("name").value;
$.post("AddServlet", {
name:$cityName
}, function(xml) {
$("#feedback").html(
$("result", xml).text()
);
});
});
});
In Servlet
String name= request.getParameter("name");
if (name.equals("shahid")) {
response.setContentType("text/xml");
out.println("<result>You are shahid</result>");
}
else{
response.setContentType("text/xml");
out.println("<result>You are not shahid</result>");
}
This is working fine! but I want to change the background color of div (feedback) accordingly , means if condition true, background color should be Green otherwise background color should be Red (else)