$.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");
}
});
当我上面的代码运行时,它抛出我的错误块,并说跨域获取Ajax请求抛出分析错误
SyntaxError: invalid label
[Break On This Error]
{"version":"v20","rCode":100,"results":[{"geoPostalCode":"902
虽然它也表明readyState=4, status=200, statusText="success"
和parsererror
如果我打的网址,我可以看到正确的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}]}`
请指教。我不'想写一个服务器端脚本。
该内容不是JSONP。这是常规的JSON。 – 2013-04-25 06:57:52
okie,如何拨打正确的电话?我尝试没有jsonp也没有工作。 – 2013-04-25 07:02:23