JSONP returning "Uncaught SyntaxError: Unexpected token :"
This question already has an answer here:
I'm guessing you have omitted some of the code.
First, when Chrome give you that error, you can click on it in the console window and it will show you the exact line that the error is being thrown.
Also, it seems like your code is a little more verbose than it need be.
$.ajax({
type: "GET",
dataType: "jsonp",
url: "http://divvybikes.com/stations/json",
success: function (data) {
console.log(data);
}
});
The return type should be JSONP but its currently returning JSON
example
//JSON
{"name":"abc","id":0}
//JSONP format
func({"name":"def","id":1});
also ensure that the JSON returned is valid.
Copy the returned json. Open http://jsonlint.com/
Paste your whole json there and validate. You may find issues with your json returned. Get that right and try again
链接地址: http://www.djcxy.com/p/46012.html