JSON案。
$(document).ready(function() {
jQuery.ajax({
type: GET ,
url: http://wncrunners.com/admin/colors.json ,
dataType: jsonp ,
success: function(data) {
alert( success );
}
});
});//end document.ready
RAW要求:
GET http://wncrunners.com/admin/colors.json?callback=jQuery16406345664265099913_1319854793396&_=1319854793399 HTTP/1.1
Host: wncrunners.com
Connection: keep-alive
Cache-Control: max-age=0
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.106 Safari/535.2
Accept: */*
Referer: http://localhost:8888/jquery/Test.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
The RAW Response:
HTTP/1.1 200 OK
Date: Sat, 29 Oct 2011 02:21:24 GMT
Server: Apache/1.3.33 (Unix) mod_ssl/2.8.22 OpenSSL/0.9.7d SE/0.5.3
Last-Modified: Fri, 28 Oct 2011 17:48:47 GMT
ETag: "166a2402-10-4eaaeaff"
Accept-Ranges: bytes
Content-Length: 16
Content-Type: text/plain
Connection: close
{"red" : "#f00"}
JSON正在回复中(红点:#f00),但 Chrome报告。 UncaultyntaxError: Unexpected token :nuts.json:1
If I navigate directly to url itself, the JSON is returned and is displayed in the browser.
如果我主宰肤色的内容。 json into JSLINT, the json accreditations.
有什么想法,我为什么会发现这一错误,我从来不会给成功带来挫折?
EDIT - 上文提到的j Query.ajax()电话在jsfiddle.net运行良好,并按预期恢复警戒。
EDIT 2 - this URL works fine http://api.wunderground.com/api/8ac447ee36aa2505/geolookup/conditions/q/IA/Cedar_Rapids.json I noticed that it returned as TYPE: text/javascript and Chrome did not throw the Unexpected Token. I ve tested several other url s and the ONLY one that does not throw the Unexptected Token is the wunderground that is returned as TYPE: text/javascript.
Streams returned as text/plain and application/json are not being parsed correctly.