# Quote Machine Help Please!

**URL:** <https://forum.freecodecamp.org/t/quote-machine-help-please/5914>\
**Category:** General\
**Created:** [May 29, 2016, 12:20pm UTC](https://forum.freecodecamp.org/t/quote-machine-help-please/5914 "2016-05-29T12:20:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamesthemonkeh](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jamesthemonkeh/32/13662_2.png) [@jamesthemonkeh](https://forum.freecodecamp.org/u/jamesthemonkeh)\
**Post date:** [May 29, 2016, 12:20pm UTC](https://forum.freecodecamp.org/t/quote-machine-help-please/5914/1 "2016-05-29T12:20:58Z")

</div>

Hello

I’m wondering if someone might have 5 minutes to point me in the right direction for fixing my random quote machine?

The first time that I’m using JSON, and I’m getting a bit muddled. I’m trying to use json.parse but something is going wrong.

My codepen is here - [http://codepen.io/jameswinfield/pen/JXYyjB](http://codepen.io/jameswinfield/pen/JXYyjB)

Thanks  
James

---

<div class="post-metadata">

**Author:** ![lincore](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lincore/32/101809_2.png) [@lincore](https://forum.freecodecamp.org/u/lincore)\
**Post date:** [May 29, 2016, 3:42pm UTC](https://forum.freecodecamp.org/t/quote-machine-help-please/5914/2 "2016-05-29T15:42:43Z")

</div>

@jamesthemonkeh  
Hey James, let me explain what’s going wrong:

_(update: re-read your code, answer updated)_

- You try to use the value returned by `$.getJSON`, which is not what you think it is. It is not json, but a so called `jsXHR`-object. This thing offers additional functionality, like the ability to specify a function that gets called when your request fails etc. `$.getJSON` does not return json directly, because it takes some time to get it, If it would, your script had to wait until your request reached the server, the server collected the requested data and you got the results. You can’t know how long that will take, so it’s common in web development to provide a function that gets called back when the results are in.  
What you actually want to use is the first argument of the success function, which is called `json` in your case.
- In your success handler for `$.getJSON`, you call `$.parseJSON(jsonstuff)`. As already established, `jsonstuff` is not json. Even if you used `json` instead, it still wouldn’t work, `json` has already been parsed for you convenience. You can look it up in the [jQuery documentation](http://api.jquery.com/jQuery.getJSON/). So tl;dr: use json.author, json.quote.
- This is almost correct: `$('.quote').html(author);`  
Assuming `.quote` should contain the quote, use `json.quote`. Also, use `$('.quote').text(json.quote)` instead of `html()`, as you only want to change the text, not the markup. In this case, it doesn’t really matter,  
but it’s good practice to be precise. You probably want to add another div/etc. for the author, where you can use the same code. Remove everything else.

---

<div class="post-metadata">

**Author:** ![AungMyoKyaw](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/aungmyokyaw/32/285707_2.png) [@AungMyoKyaw](https://forum.freecodecamp.org/u/AungMyoKyaw)\
**Post date:** [May 30, 2016, 1:59pm UTC](https://forum.freecodecamp.org/t/quote-machine-help-please/5914/3 "2016-05-30T13:59:08Z")

</div>

I think the correct way to complete this challenge is using [**Random Famous Quotes**](https://market.mashape.com/andruxnet/random-famous-quotes) api.  
I think the problem is ajax request.  
I have trouble how to request.  
I found sample code to execute this request in this [link](http://blog.mashape.com/mashape-sample-code-executing-ajax-request-using-jquery/).

[http://rqm.aungmyokyaw.com/](http://rqm.aungmyokyaw.com/)

[Source Code](https://github.com/AungMyoKyaw/rqm)

---

<div class="post-metadata">

**Author:** ![jamesthemonkeh](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jamesthemonkeh/32/13662_2.png) [@jamesthemonkeh](https://forum.freecodecamp.org/u/jamesthemonkeh)\
**Post date:** [May 30, 2016, 2:04pm UTC](https://forum.freecodecamp.org/t/quote-machine-help-please/5914/4 "2016-05-30T14:04:46Z")

</div>

Oh my, it’s miles simpler than I was attempting!!

I’ve forked it to here - and it’s working! [http://codepen.io/jameswinfield/pen/VjwEZg](http://codepen.io/jameswinfield/pen/VjwEZg)

Thanks  
James

---

<div class="post-metadata">

**Author:** ![jamesthemonkeh](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jamesthemonkeh/32/13662_2.png) [@jamesthemonkeh](https://forum.freecodecamp.org/u/jamesthemonkeh)\
**Post date:** [June 2, 2016, 5:29pm UTC](https://forum.freecodecamp.org/t/quote-machine-help-please/5914/5 "2016-06-02T17:29:33Z")

</div>

Aaaarrrrrgggh it’s now totally stopped working.

---

<div class="post-metadata">

**Author:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [January 16, 2021, 3:46am UTC](https://forum.freecodecamp.org/t/quote-machine-help-please/5914/6 "2021-01-16T03:46:58Z")

</div>

Closed on January 16, 2021, 3:46am UTC


