-2

How can I get Json information from a website API in javascript?

I need to get quotes text from this website http://forismatic.com/en/api/ to put in my quotes generator page. I think I kinda of get how to great GET requests, but from my understanding this API requires POST requests.

If you have any idea, could you also direct me to the explanation of the code you've written, because I'd also like to understand the underlying logic.

Thanks!

Paolo Caponeri
  • 127
  • 4
  • 15

1 Answers1

-3

Try this.. Its already working, JSONP

function insertReply(content) {
    document.getElementById('output').innerHTML = content;
}

// create script element
var script = document.createElement('script');
// assing src with callback name
script.src = 'http://url.to.json?callback=insertReply';
// insert script to document and load content
document.body.appendChild(script);
Community
  • 1
  • 1