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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:47:16+00:00 2026-06-03T13:47:16+00:00

It seems very inconvenient that jQuery’s $.getJSON silently fails when the data returned is

  • 0

It seems very inconvenient that jQuery’s $.getJSON silently fails when the data returned is not valid JSON. Why was this implemented with silent failure? What is the easiest way to perform getJSON with better failure behavior (e.g. throw an exception, console.log(), or whatever)?

  • 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-03T13:47:17+00:00Added an answer on June 3, 2026 at 1:47 pm

    you can use

            function name() {
                $.getJSON("", function(d) {
                    alert("success");
                }).done(function(d) {
                    alert("done");
                }).fail(function(d) {
                    alert("error");
                }).always(function(d) {
                    alert("complete");
                });
            }
    

    If you want to see the cause of the error, use the full version

    function name() {
        $.getJSON("", function(d) {
            alert("success");
        }).fail( function(d, textStatus, error) {
            console.error("getJSON failed, status: " + textStatus + ", error: "+error)
        });
    }
    

    If your JSON is not well-formed, you will see something like

    getJSON failed, status: parsererror, error: SyntaxError: JSON Parse error: Unrecognized token '/'
    

    If the URL is wrong, you will see something like

    getJSON failed, status: error, error: Not Found
    

    If you are trying to get JSON from another domain, violating the Same-origin policy, this approach returns an empty message. Note that you can work around the Same-origin policy by using JSONP (which has it’s limitations) or the preferred method of Cross-origin Resource Sharing (CORS).

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

Sidebar

Related Questions

I have an issue that seems like very flaky behavour, is this a problem
This seems very strange to me but I have a script that I'm running
this seems very simple and im puzzled as to why its not working...I want
Im interested in implementing a JQuery solution for a Panel Selector that seems very
I do realize that this question seems very well known, but since I don't
This seems very basic and I must be missing something, but here goes anyways...
This seems very foolish mistake, I just did a git stash pop on a
Most of Knockout seems very intuitive. One thing that is strange to me though
This seems very basic but I can't figure it out. I've got a table
s is a string, This seems very long-winded - how can i simplify this?

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.