$.ajax({
type: "GET",
url: "http://api.zip-tax.com/request/v20",
data: {
key: '1234567890',
postalcode: '90265',
format: 'json'
},
success: function (json) {
debugger;
// do stuff with json (in this case an array)
alert("Success");
},
error: function (a, b, c) {
debugger;
alert("Error");
}
});
当我运行上面的代码时,它把我扔进错误块并说
SyntaxError: invalid label
[Break On This Error]
{"version":"v20","rCode":100,"results":[{"geoPostalCode":"902
虽然它也显示readyState=4, status=200, statusText="success"
,parsererror
如果我点击那个 url,我可以看到正确的 json
URL: `http://api.zip-tax.com/request/v20?key=1234567890&postalcode=90265&format=json`
Result: `{"version":"v20","rCode":100,"results":[{"geoPostalCode":"90265","geoCity":"MALIBU","geoCounty":"LOS ANGELES","geoState":"CA","taxSales":0.090000003576279,"taxUse":0.090000003576279,"txbService":"N","txbFreight":"N","stateSalesTax":0.064999997615814,"stateUseTax":0.064999997615814,"citySalesTax":0,"cityUseTax":0,"cityTaxCode":"","countySalesTax":0.0099999997764826,"countyUseTax":0.0099999997764826,"countyTaxCode":"19","districtSalesTax":0.014999999664724,"districtUseTax":0.014999999664724},{"geoPostalCode":"90265","geoCity":"PT DUME","geoCounty":"LOS ANGELES","geoState":"CA","taxSales":0.090000003576279,"taxUse":0.090000003576279,"txbService":"N","txbFreight":"N","stateSalesTax":0.064999997615814,"stateUseTax":0.064999997615814,"citySalesTax":0,"cityUseTax":0,"cityTaxCode":"","countySalesTax":0.0099999997764826,"countyUseTax":0.0099999997764826,"countyTaxCode":"19","districtSalesTax":0.014999999664724,"districtUseTax":0.014999999664724},{"geoPostalCode":"90265","geoCity":"TWAIN HARTE","geoCounty":"VENTURA","geoState":"CA","taxSales":0.075000002980232,"taxUse":0.075000002980232,"txbService":"N","txbFreight":"N","stateSalesTax":0.064999997615814,"stateUseTax":0.064999997615814,"citySalesTax":0,"cityUseTax":0,"cityTaxCode":"","countySalesTax":0.0099999997764826,"countyUseTax":0.0099999997764826,"countyTaxCode":"56","districtSalesTax":0,"districtUseTax":0}]}`
请指教。我不想编写服务器端脚本。