I'm trying to fetch data from wooCommerce api in an angularjs application using jsonp
method
$http.jsonp('http://pwoo.dev/wc-api/v2?callback=JSON_CALLBACK')
.success(function ( data, status, headers, config ) {
console.log(data, status, headers, config);
})
.error(function ( data, status, headers, config ) {
console.log("Error", data, status, headers, config);
});
and in return it gives me this error in console
Uncaught SyntaxError: Unexpected token :
and breaks the code in error block
here is the live link from same type of api I used in fiddle above
I have validated the json online and its correct and valid in format, you check it here in fiddle's console in the following link
Update:
Ok its not working for jQuery.ajax
as well check the fiddle below where I have used simple jquery's $.ajax
method with dataType: "jsonp"
I don't understand where is the issue because in my above angular example a simple test.json with data
{
"name": "zeeshan Lalani"
}
throws same error. What m'I missing here? How people in this world use JSONP
examples ? :(
The
jsonp
content should be between a callback function like: