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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:45:01+00:00 2026-05-25T09:45:01+00:00

I’m having a problem where a .getJSON request doesn’t throw any errors, or anything,

  • 0

I’m having a problem where a .getJSON request doesn’t throw any errors, or anything, it successfully enters the callback function (which says to me the request succeeded, yes?) but never exits. The entire callback function is executed, the data is read correctly, but it never exits.

function getResult(option){

     console.log("inside getResult");
        $.getJSON(yql, function(data){
          console.log("inside getJSON");
          var directions = '';
          $(data.query.results.div).each(function(i,element){
            htmlimg=(typeof(element.img) != 'undefined') ? '<img src="'+element.img.src+'" alt="'+element.img.alt+'">' : '';
            switch(typeof(element.p)){
              case 'undefined':
                htmlp = '';
                break;
              case 'string':
                if(element.p == 'Alternative routes:'){
                  //end looping
                  return false;
                }
                htmlp = '<p>' + element.p + '</p>';
                break;
              case 'object':
                function showhtmlp(element){
                  var s = '';
                  if(typeof(element.content != 'undefined')){
                    s += element.content;
                  }
                  if(typeof(element.a) != 'undefined'){
                    s += element.a.content;
                  }
                  if(typeof(element.br) != 'undefined'){
                    s+='<br>';
                  }
                  return s
                }

                htmlp = '<p>';
                if(typeof(element.p[0]) != 'undefined'){
                  $(element.p).each(function(i, data){
                    htmlp += showhtmlp(data);
                  });
                } else {
                  htmlp += showhtmlp(element.p);
                }
                htmlp += '</p>';
                break;
            }
            directions += '<div>'+htmlimg+htmlp+'</div>';
    console.log("Directions: ");
    console.log(directions);
          });
    console.log("OUT OF DIRECTIONS EACH FUNCTION/LOOP");
          directions += '<div><a href="' + data.query.diagnostics.url.content + '" target="_blank" title="See on Google Maps"><img src="images/link.png" alt="Link" class="smallicon">View trip on Google Transit</a></div>';
    console.log("step1");
          trip.transit.routes[option].directions = directions;
    console.log("step2");
          $('#transitoption'+option).html(directions);
    console.log("step3");
        });//end of .getJSON
    console.log("out of JSON");
      }//end of getResult?
    console.log("out of Result");
      getResult(option);

the console.log command of “before end” is printed out. No errors are thrown. However, it never reaches the console.log of “out of JSON”.

When I tried to use the console to debug I saw it getting stuck in a portion of the jquery.min.js code that, while minimized, I could tell had words like “abort” and “timeout” in it.

I’m relatively new to ajax requests, so please be very specific.

the yql variable is:

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fmaps.google.com%2Fm%2Fdirections%3Fsaddr%3D37.78414%2C%2B-122.44108%26daddr%3D37.61688%2C%2B-122.38400999999999%26dirflg%3Dr%26ri%3D0%26date%3D2011-09-02%26time%3D9%3A21pm%22%20and%20xpath%3D'%2F%2Fdiv%2Fdiv'&format=json&diagnostics=true
  • 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-25T09:45:02+00:00Added an answer on May 25, 2026 at 9:45 am

    Do you realize that the JSON call is asynchronous. That means that when you call getJSON, you are just initiating the ajax call. That function will return immediately (and you should see “out of JSON” right away before either of the other statements (unless you have JS errors). Then, when the ajax call succeeds later, you should see “inside getJSON” and “before end” from the success handler function. If you aren’t seeing these, then you may have some javascript errors somewhere that are halting execution. You should be checking your error console or debugger console to look for JS errors.

    My guess is that either you aren’t understanding the order that things happen in and that has you confused or you have JS errors that are halting execution.

    It would also help us identify problems if you post the whole code for your getJSON call.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.