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

  • Home
  • SEARCH
  • 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 6703049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:07:34+00:00 2026-05-26T07:07:34+00:00

Here is my code: var source; source = $.getJSON(url, function(json) { return console.log(json); });

  • 0

Here is my code:

var source;
source = $.getJSON(url, function(json) {
  return console.log(json);
});

The above is returning the full jQuery object vs the JSON I am requested. The response looks something like this:

abort: function ( statusText ) {
always: function () {
complete: function () {
done: function () {
error: function () {
fail: function () {
getAllResponseHeaders: function () {
getResponseHeader: function ( key ) {
isRejected: function () {
isResolved: function () {
overrideMimeType: function ( type ) {
pipe: function ( fnDone, fnFail ) {
promise: function ( obj ) {
readyState: 4
responseText: "{'Hello':'World'}"
setRequestHeader: function ( name, value ) {
status: 200
statusCode: function ( map ) {
statusText: "OK"
success: function () {
then: function ( doneCallbacks, failCallbacks ) {
__proto__: Object

Anyone know what I am doing wrong? I have been dealing with this for a couple of hours now 🙁

  • 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-26T07:07:34+00:00Added an answer on May 26, 2026 at 7:07 am

    AJAX is asynchronous, source cannot equal the JSON you are requesting, because it isn’t available yet. jQuery.getJSON will return the jqXHR object it creates to deal with the request and then runs away and retrieves the response.

    $.getJSON(url, function(json) {
      // deal with response  here
    });
    

    Upon the response being available (some time later), the callback (the function you’re passing) is executed, so you can access the response in there via the first parameter (which you’ve called json).

    You can see this by trying the following:

    console.log('1');
    
    $.getJSON(url, function(json) {
        console.log('2');
    });
    
    console.log('3');
    

    You’ll see that your console will read 1, 3, and then a split second later (i.e. the time to perform the HTTP request), 2; This shows the getJSON response returning without completing, the script continuing to execute, and then the callback being invoked some time later.

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

Sidebar

Related Questions

Here is my code: var showNo = 1; window.setInterval(function() { console.log(showNo); if(showNo === 1)
I wrote this code: function json() { var url=http://192.172.2.23:8080/geoserver/wfs?request=GetFeature&version=1.1.0&outputFormat=json&typeName=topp:networkcoverage&CQL_FILTER= topp:CELL_ID='410-07-301-31781' Or topp:CELL_ID='nnn'&callback=?; jQuery.getJSON(url,function(data){alert(Symbol: +
Here is my chunk of code: var update_shipping_methods = function(methods) { $(methods).each( function(i) {
Here is my code: function pauseSound() { var pauseSound = document.getElementById(backgroundMusic); pauseSound.pause(); } I
I have this code here: var infiltrationResult; while(thisOption) { var trNode = document.createElement('tr'); var
Here is a portion of my code: var styles:String = .keyword{color: #ff0000;} .comment{color: #00ff00;};
Right, starting to go crazy here. I have the following code: var query =
Here's the code I have: var commandsBuffer = List[String]() commandsBuffer ::= cmd.exe commandsBuffer ::=
The code in question is here: var $item = $(this).parent().parent().find('input'); What is the purpose
Given some JS code like that one here: for (var i = 0; i

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.