Change div backgroung color base on result from servlet using jquery

Posted by Both FM on Stack Overflow See other posts from Stack Overflow or by Both FM
Published on 2012-04-08T05:16:15Z Indexed on 2012/04/08 5:29 UTC
Read the original article Hit count: 204

Filed under:
|
|
|
|

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)

© Stack Overflow or respective owner

Related posts about java

Related posts about JavaScript