Help with json with jquerry

Hello guys please give me a minute of your time. Am working on the random code generator and am stuck.I’ve created my own funny quotes in a json file.But when I use $.getJSON I either get “syntax error”, “not well-formated” or " XMLHttpRequest cannot load" .please help me.I’ve been stuck for days.

Could you provide some code? Are you sure your JSON file is valid? Try pasting it in and see if you get any errors.

1 Like

Hey…thanks for your help.
Can you please review my random quote machine?
I want a honest review.
thanks in advance.

You needed to move these 3 lines:

    tweetLink = "" + quote;
    $(".tweetLink").attr("href", tweetLink);   

inside your getJSON success function like so:

  var quote;
  var tweetLink;
      tweetLink = "" + quote;
      $(".tweetLink").attr("href", tweetLink);      

Because the getJSON function is asynchronous, those 3 lines of code outside the getJSON success function were running before the data was back from the API.

1 Like

thanks a lot.
really appreciate it

Csn you help me with this?
I cant see what am doing wrong.
Its just not giving me the longitude and latitude.
Its saying its undefined.

Same type of problem you had in the original post.

navigator.geolocation.getCurrentPosition is asynchronous function so you must put any code dealing with the values retrieved back from it inside the anonymous function (the success). You can also use a second argument (also a function) which is used to execute in the event an error occurs during the API call.

See if you can figure out how to solve your problem now that I have given you this information.

1 Like

thanks a lot…it worked.
the reply was quick too.
so are all jquerry functions asynchronous functions?

Not all, but those which use callback functions such as .ajax or .getJSON do.

The navigator.geolocation.getCurrentPosition is a pure JavaScript function and is not related to JQuery.

hey…Am finally done with the weather app
Your reviews are highly welcomed.

One suggestion is to read about the toFixed function to limit the number of decimals displayed in your temperatures. Currently, the Celsius version has two decimals and the Fahrenheit version has 14. Also, you have not met all the required user stories for the project. I do not see a background or icon which shows the current weather condtions (i.e. sunny skies, cloudy skies, rain, snow, etc…).

1 Like

there’s an icon beside the temperature

Hey… please help me with my wiki viewer.
is something wrong with the Json data?

Check the browser’s console (Ctrl+Shft+I in Chrome). You have an error you should research. This is a common error for campers working on the Wikipedia project, so use the search feature in the forum first.

1 Like

It works great now. Found a useful article on the forum.
And thanks for always responding on time.
I appreciate it a lot.