jQuery ajax API call with JSONP data type is failing
in Using jQuery
•
6 years ago
I am building client application( using Jquery and HTML but no server side language) to access API call publish by NPPES website- https://npiregistry.cms.hhs.gov/registry/API-Examples I am using JSONP data types to avoid same origin policy in browser call but Ajax call is giving error and don't go to success callback. e.g I am trying to call this : https://npiregistry.cms.hhs.gov/api?number=1073500443 ( if i directly invoke this in browser it gives json data back |
$(document).ready(function(){
$("button").click(function(){
var api="https://npiregistry.cms.hhs.gov/api?number=1073500443";
$.ajax({
type: "POST",
dataType: "jsonp",
url: api,
success: function() {console.log( "successful" )},
error : function(){console.log('error')},
});
});
}):
am getting this error as the call is not successful. Is this website is not made to call jsonp request as it not responsing jsonp callback function. Uncaught SyntaxError: Unexpected token : textStatus: parsererror
any idea or workaround ? I tried all possible combination but no luck.
appreciate if someone try to access this api and if that works for them or not ?
1