为什么即使 Fiddler 没有报告错误,下面的 jQuery ajax 也总是调用错误回调:
$.ajax({
type: 'GET',
url: "http://open.mapquestapi.com/nominatim/v1/search?format=json&viewbox=-122%2C46%2C-73%2C40&countrycodes=ca&bounded=1&addressdetails=0&q=[hotel]",
dataType: 'jsonp',
jsonp: 'json_callback',
error: function(parameters) {
alert(parameters);
},
success: searchCompleteCallBack
});
这是 Fiddler 会话,虽然成功,但有一个带有横线的红色圆圈作为状态图标,如下所示:
GET /nominatim/v1/search?format=json&viewbox=-122%2C46%2C-73%2C40&countrycodes=ca&bounded=1&addressdetails=0&q=[hotel]&json_callback=jQuery17108850838504386628_1334974646679&_=1334974661295 HTTP/1.1
Accept: application/javascript, */*;q=0.8
Referer: http://localhost:50383/?AspxAutoDetectCookieSupport=1
Accept-Language: en-US
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; BOIE9;ENGB)
Accept-Encoding: gzip, deflate
Host: open.mapquestapi.com
Connection: Keep-Alive
HTTP/1.1 200 OK
Date: Sat, 21 Apr 2012 02:17:41 GMT
Server: Apache
Content-Location: search.php
Vary: negotiate
TCN: choice
Access-Control-Allow-Origin: *
Content-Length: 4775
Keep-Alive: timeout=5, max=91
Connection: Keep-Alive
Content-Type: application/json; charset=UTF-8
jQuery17108850838504386628_1334974646679([{"place_id":"2166467243","licence":"Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.","osm_type":"node","osm_id":"1417990074","boundingbox":["43.0738813782","43.0938851929","-79.0912683105","-79.0712606812"],"lat":"43.0838817","lon":"-79.0812662","display_name":"Quality Hotel, Murray Street, Niagara Falls, Ontario, Ontario, Canada","class":"tourism","type":"hotel","icon":"http://open.mapquestapi.com/nominatim/v1/images/mapicons/accommodation_hotel2.p.20.png"},{"place_id":"2085733959","licence":"Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.","osm_type":"way","osm_id":"97928121","boundingbox":["49.8510055541992","49.8513870239258","-97.1532821655273","-97.1526718139648"],"lat":"49.8512060913871","lon":"-97.1530114466667","display_name":"Pembina Hotel, 1011, Pembina Highway, Point Road, Winnipeg, Manitoba, Canada","class":"amenity","type":"hotel"},{"place_id":"2152638544","licence":"Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.","osm_type":"node","osm_id":"1324405899","boundingbox":["43.8393080139","43.8593118286","-79.3921792603","-79.3721716309"],"lat":"43.849309","lon":"-79.382178","display_name":"Holiday Inn Express & Suites, Fulton Way, Thornlea, Markham, Ontario","class":"tourism","type":"hotel","icon":"http://open.mapquestapi.com/nominatim/v1/images/mapicons/accommodation_hotel2.p.20.png"},{"place_id":"2177668535","licence":"Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.","osm_type":"way","osm_id":"138157978","boundingbox":["43.4092330932617","43.4098968505859","-80.3297119140625","-80.3289260864258"],"lat":"43.40953956119","lon":"-80.3293440133707","display_name":"Hespeler Road, Cambridge, Ontario, Canada","class":"tourism","type":"hotel","icon":"http://open.mapquestapi.com/nominatim/v1/images/mapicons/accommodation_hotel2.p.20.png"},{"place_id":"2138545308","licence":"Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.","osm_type":"node","osm_id":"1280026038","boundingbox":["43.6322805786","43.6522843933","-79.4218270874","-79.401819458"],"lat":"43.6422834","lon":"-79.4118234","display_name":"Palace Arms, Strachan Avenue, Liberty Village, Toronto, Ontario, M5A1Z9, Canada","class":"tourism","type":"hostel"},{"place_id":"5773486","licence":"Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.","osm_type":"node","osm_id":"583902387","boundingbox":["45.3422987366","45.3623025513","-75.6427056885","-75.6226980591"],"lat":"45.3522996","lon":"-75.6327046","display_name":"Bank Street, Blossom Park, Ottawa, Ontario","class":"tourism","type":"hotel","icon":"http://open.mapquestapi.com/nominatim/v1/images/mapicons/accommodation_hotel2.p.20.png"},{"place_id":"2170250899","licence":"Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.","osm_type":"node","osm_id":"1445914835","boundingbox":["43.1746237183","43.194627533","-79.5842340088","-79.5642263794"],"lat":"43.1846249","lon":"-79.5742298","display_name":"Beamer Falls Manor at Falconridge Farm, Ridge Road West, Grimsby, Ontario, Canada","class":"tourism","type":"hotel","icon":"http://open.mapquestapi.com/nominatim/v1/images/mapicons/accommodation_hotel2.p.20.png"},{"place_id":"2664364","licence":"Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.","osm_type":"node","osm_id":"343055090","boundingbox":["43.6355078125","43.6555116272","-79.4053170776","-79.3853094482"],"lat":"43.6455088","lon":"-79.3953127","display_name":"Global Village Backpackers Hostel, King Street West, Fashion District, Toronto, Ontario, M5A1Z9, Canada","class":"tourism","type":"hostel"},{"place_id":"2168185190","licence":"Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.","osm_type":"way","osm_id":"129431482","boundingbox":["45.3853416442871","45.3861045837402","-75.733268737793","-75.7327346801758"],"lat":"45.3857092561038","lon":"-75.7330025913023","display_name":"Best Western Macies Hotel, Carling Avenue, Rideauview, Ottawa, Ontario, Canada","class":"tourism","type":"hotel","icon":"http://open.mapquestapi.com/nominatim/v1/images/mapicons/accommodation_hotel2.p.20.png"},{"place_id":"2166467244","licence":"Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.","osm_type":"node","osm_id":"1417990095","boundingbox":["43.0724356079","43.0924394226","-79.0928704834","-79.072862854"],"lat":"43.0824382","lon":"-79.0828672","display_name":"Hilton Niagara Falls, Fallsview Boulevard, Niagara Falls, Ontario, Ontario, Canada","class":"tourism","type":"hotel","icon":"http://open.mapquestapi.com/nominatim/v1/images/mapicons/accommodation_hotel2.p.20.png"}])
实际上,我不久前就进行了这项工作,但现在无法弄清楚我做错了什么。