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 6047087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:18:46+00:00 2026-05-23T07:18:46+00:00

Restful Service (from Server) @GET @Produces(application/json) @Consumes(application/json) @Path(/getStatus/) // server:8080/server/rest/admin/status/whatSoEver public void getStatus( @Context

  • 0

Restful Service (from Server)

  @GET
  @Produces("application/json")
  @Consumes("application/json") 
  @Path("/getStatus/")
  // server:8080/server/rest/admin/status/whatSoEver
  public void getStatus(
      @Context HttpServletRequest request,
      @Context HttpServletResponse response) throws ServletException,
      IOException
  {

      //create the JSON Object to pass to the client
      JSONObject object=new JSONObject();


             response.setContentType("text/javascript");  

             String callback = request.getParameter("jsoncallback");  

             try
             {  
               for (Server i : svr)
               {
                 object.put("name",getName());
                 object.put("status",getStatus());

               }

             }
             catch(Exception e)
             {  
                  throw new ServletException("JSON Hosed up");  
             }  


               String json = object.toString();  

               /*response.getOutputStream().println(callback + "(" + json + ");");*/

               response.getOutputStream().print(json);
               response.flushBuffer();

               System.out.println("Sending "+json);
  }

On the client side

<script>


 $(document).ready(function() 
 {

    function myFunc() 
    {
         $.getJSON("http://localhost:8080/MyWebApp/getStatus",
        function (json) 
        {  
            $('#refreshMe').replaceWith(json.status);
            /* alert("Server name: " + json.name + "Server Status:"+json.status); */
        });
    }

    myFunc();
 });


    /*Do a refresh every 2 seconds */
    setInterval( "myFunc()", 500 );


</script>

How do I get this jquery ajax call to
behave the same as the above?

<script>


   $.ajaxSetup ({ cache: false  });  

    $.ajax
    ({
        url: "http://localhost:8080/MyWebApp/getStatus",
        dataType: 'json',
        data: "???",
        success: ???
    });

</script>
  • 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-05-23T07:18:47+00:00Added an answer on May 23, 2026 at 7:18 am

    Like so:

        <script>
        $.ajaxSetup({
            cache: false
        });
    
        $.ajax({
            url: "http://localhost:8080/MyWebApp/getStatus",
            dataType: 'json',
            success: function(json) {
                $('#refreshMe').replaceWith(json.status);
            }
        });
        </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to call a RESTful web service from an Android application using the
I have an lxml.objectify data structure I get from a RESTful web service. I
Should the representation(html, xml, json) returned by a RESTful web service be determined by
Hi can anyone past some code how to do a restful web service get
I am using Cherrypy in a RESTful web service and server returns XML as
I am implementing a RESTful web service that currently handles JSON and needs to
I need to do some GETing and POSTing to a RESTful web service from
I want to call some RESTful web services from a J2ME client running on
I have a RESTful service that I am developing in WCF . I am
I have a RESTful web service deployed at http://example.com/v1/SomeResource . One day, a new

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.