Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7774341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:21:13+00:00 2026-06-01T17:21:13+00:00

Java Script Code Snippet $(document).ready(function() { $(#button).click(function(){ $cityName = document.getElementById(name).value; $.post(AddServlet, { name:$cityName },

  • 0

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)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:21:14+00:00Added an answer on June 1, 2026 at 5:21 pm

    I think XML is used only for carrying data or represent metedata like DTD and so on,

    if you want to do something like change your color etc. then you can use

      response.setContentType("text/html");
      out.println("<div id="result" style="color: blue">You are not shahid</div>");
    

    hope this may help you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my code and in this i wanna call a java script function
I have java script code to set some of the properties of ajax controls.
How to embed java-script in the java code written in gwt.Please give me an
I want to call shell script on windows environment using java code. I am
I'm writing a Groovy script which uses third party java code that I can't
In the following code snippet: <form> <fieldset> <button id=indexGetStarted class=button type=submit>Get Started!</button> </fieldset> </form>
Edit This is the function where I get the response from $(document).ready(function() { $.ajax({
I tested this code snippet but the first function is not executing while the
I have code snippet like below I am facing problem when I click on
Consider a javascript code snippet, which uses JSON to get twitter followers count. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.