Hello, i am building my first project but i am stuck at implementing the API with jQuery, i am trying to do it step by step like the lessons but it doesn’t works, even showing the content with .stringify! Can you give me some tips?
Regards !
Hello, i am building my first project but i am stuck at implementing the API with jQuery, i am trying to do it step by step like the lessons but it doesn’t works, even showing the content with .stringify! Can you give me some tips?
Regards !
Could you post a link to your project?
It’s hard to give any kind of useful advice based on your description alone.
https://codepen.io/Stivi7/pen/qXRReW?editors=1010 here is my code, i have seen different references and tutorials but still doesnt work, it is driving me crazy!
thanks in advance
You forgot to import jQuery.
If you haven’t used codepen before, just click on the gear next to the Javascript field, and use quick-add to select it.
Also, depending on whether you’re using https everywhere or not, you might have a problem calling an http link. If that’s the case, simply change the ajax request link from http to https.
I hope that helps!
I imported jQuery now but still nothing where can i change the ajax request link?
At $getJson.
Try:
$.getJSON(“https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=”, function(data){
$(“.message”).html(data[0].content + " - " + data[0].title)
instead of:
$.getJSON(“http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=”, function(data){
$(“.message”).html(data[0].content + " - " + data[0].title)
It worked for me after importing jQuery, and changing that.
thanks man, i love you such a great help
No problem!
Have fun coding!
I prefer that method rather than using ajax to view APIs.