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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:14:43+00:00 2026-05-26T19:14:43+00:00

I am working on making a mini app using Json parsing . Output I

  • 0

I am working on making a mini app using Json parsing . Output I am getting by hitting url http://localhost:3000/cities.json is as below

[
    {
    "id": 1,
    "name": "Bangalore"
    },
    {
    "id": 2,
    "name": "Chandigarh"
    },
    {
    "id": 3,
    "name": "Chennai"
    },
    {
    "id": 4,
    "name": "Hyderabad"
    },
]

I have parsed this using function

  $.getJSON("http://localhost:3000/cities.json?&callback=?", function(data) {
                //something something
 }

Now I want to add .error function to it so in case there is some issue with response or say server doesnt respond i may get to know about it say by putting an alert like

.error(function(){alert("error");})

I tried it in following way

  $.getJSON("http://localhost:3000/cities.json?&callback=?", function(data) {
                //something something
         }).error(function(){
            alert("error");
         })

I tried it using this way as well

     var cities = $.getJSON("http://localhost:3000/cities.json");
                   cities.error("hi");        

But none of them is working. To check for error i stop my local server and it doesnt give me any alert for that . Please guide me which way should i proceed ?

——EDIT——–

Also tried using

 var jqxhr = $.getJSON("http://localhost:3000/cities.json?callback=?", function() {
          alert("success");
        })
        .success(function() { alert("second success"); })
        .error(function() { alert("error"); })
        .complete(function() { alert("complete"); });

in case my localhost:3000 server is running it give me alert success and second success but in case i stop it no error call, also making url just http://localhost:3000/cities.json
always tend to give error irrespective of server running or not

  • 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-26T19:14:43+00:00Added an answer on May 26, 2026 at 7:14 pm

    This worked for me finally

               $.ajax({
                url: "http://localhost:3000/cities.json?&callback=?",
                type: "GET",
                dataType: "json",
                timeout: 10000,
                success: function(data, status, xmlstatus) {
                    call_to_function(data);
                },
                error: function(x, t, m) {
                    if (t === "timeout") {
                        $('#spinner').hide();
                    } else {
                        $('#spinner').hide();
                    }
                }
            });
    

    Thanks

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

Sidebar

Related Questions

We're making this web app in PHP and when working in the reports we
I am working on making a paged app that will load a separate HTML
I'm working on making this web page: http://jsfiddle.net/pW8yj/ and I want to get a
I am working on making a custom section of my app.config and web.config to
I'm working on making an HTTP server for my class. But, the returned file
I am working on making a widget like this one here: http://www.comehike.com/outdoors/widget.php?hike_id=176&height=400&width=700 And for
I'm working on making a plugin for Mail.app. I'd like the plugin to add
I have been working on making a Search using Solrnet which is working the
I'm working on making a small app/script for putting my mp3's in a folder
I'm working on making a py2exe version of my app. Py2exe fails at copying

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.