I do get CORS issue when I use the dataType json hence I switched it to jsonp. I'm trying this on a custom portal field on change event. The funny thing is my block of code executes but enters error with the status code 200.
Here is my code:
function getNPPESData() {
var NPI = $('#nact_npi').val();
if (NPI != null) {
$.ajax({
type: 'GET',
url: "npiregistry.cms.hhs.gov/.../ + NPI + "",
dataType: 'jsonp',
success: function(data) {
alert('success');
},
error: function(data){
alert('failed');
}
});
}
}
The error on console when I debug:
SCRIPT1004: SCRIPT1004: Expected ';'
api (1,16)
Here is my api response:
{"result_count":1, "results":[{"enumeration_type": "NPI-1", "number": 1316459605, "last_updated_epoch": 1508976000, "created_epoch": 1508976000, "basic": {"first_name": "BIANCA", "last_name": "AARON", "credential": "MFTI, PCCI", "sole_proprietor": "NO", "gender": "F", "enumeration_date": "2017-10-26", "last_updated": "2017-10-26", "status": "A", "name": "AARON BIANCA"}, "other_names": [], "addresses": [{"country_code": "US", "country_name": "United States", "address_purpose": "LOCATION", "address_type": "DOM", "address_1": "1540 E COLORADO ST", "address_2": "", "city": "GLENDALE", "state": "CA", "postal_code": "912051514", "telephone_number": "818-244-7257", "fax_number": "818-243-5431"}, {"country_code": "US", "country_name": "United States", "address_purpose": "MAILING", "address_type": "DOM", "address_1": "4760 SEPULVEDA BLVD", "address_2": "", "city": "CULVER CITY", "state": "CA", "postal_code": "902304820", "telephone_number": "310-390-6612", "fax_number": "310-398-5690"}], "taxonomies": [{"code": "106H00000X", "desc": "Marriage & Family Therapist", "primary": true, "state": "", "license": ""}], "identifiers": []}]}