Can someone explain why my code isn’t working? My ultimate goal with this code is to get a JSON object from quotesondesign.com. I’m making use of JSONP but it doesn’t work. Can someone review my code and educate? I’d also take any resources on learning to use ajax.
The success and always case just have html functions so I can see if they run.
Code:
$('h2').on('click', function(e) {
$.ajax({
url: "http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&_jsonp=mycallback",
jsonp: "callback",
dataType: "jsonp",
success: function( response ) {
console.log( response ); // server response
$("#quoteContent").html("Byee");
},
always: function(response) {
$("#quoteContent").html("Yoo");
}
});
});