jquery.ajax를 사용하여 http://developer.pintlabs.com/brewerydb/api-documentation을 쿼리하려고합니다.JSON 형식의 Jquery.ajax API 요청으로 인해 Chrome에서 "Uncaught SyntaxError : Unexpected token :"이 발생합니다.
$.ajax({
url:"http://api.playground.brewerydb.com/beer/" + "O3tmVI" + "?key=A1029384756B&format=json",
dataType: "jsonp",
jsonpCallback: "callbackfunctie",
success:function(oData){
var returnData = oData;
console.log(returnData);
}
});
그리고 :
: 이Uncaught SyntaxError: Unexpected token :
$.getJSON("http://api.playground.brewerydb.com/beer/" + "O3tmVI" + "?key=A1029384756B&format=json&jsoncallback=?",
function(data){
console.log(data);
});
모두이 오류를 일으킬
는이 내가 시도 JQuery와 요청이 ("O3tmVI은"더미 ID가 있습니다)입니다
반환 된 json 객체는 다음과 같습니다.
{"message":"Request Successful","data":{"id":"O3tmVI","name":"The Public","description":"The Public\u2122 is a delicious easy drinking pale ale made from a simple recipe of quality grain and top notch American hops. Tawny hues of caramel and amber are a trademark of the Public ale as well as a delicious spruce crispness resulting from a beautiful abundance of hops! This beer will be produced throughout the year and serves as the foundation of our product line.","abv":"6","glasswareId":8,"availableId":1,"styleId":33,"isOrganic":"N","labels":{"icon":"http:\/\/s3.amazonaws.com\/brewerydbapi\/beer\/O3tmVI\/upload_3sdJcU-icon.png","medium":"http:\/\/s3.amazonaws.com\/brewerydbapi\/beer\/O3tmVI\/upload_3sdJcU-medium.png","large":"http:\/\/s3.amazonaws.com\/brewerydbapi\/beer\/O3tmVI\/upload_3sdJcU-large.png"},"status":"verified","statusDisplay":"Verified","servingTemperature":"cool","servingTemperatureDisplay":"Cool - (8-12C\/45-54F)","createDate":"2012-04-05 04:02:36","updateDate":"2012-04-05 04:34:17","glass":{"id":8,"name":"Tulip","createDate":"2012-04-05 04:00:04"},"available":{"id":"1","name":"Year Round","description":"Available year round as a staple beer."},"style":{"id":33,"categoryId":10,"category":{"id":10,"name":"American Ale","bjcpCategory":"10","createDate":"2012-04-05 04:00:04"},"bjcpSubcategory":"A","name":"American Pale Ale","simpleUrl":"american-pale-ale","ibuMin":"30","ibuMax":"45","abvMin":"4.5","abvMax":"6.2","srmMin":"5","srmMax":"14","ogMin":"1.045","ogMax":"1.06","fgMin":"1.01","fgMax":"1.015","createDate":"2012-04-05 04:00:04"}},"status":"success"}
I가 성공적이 유효한 JSON
이제, 문제는 내가 (크로스 도메인)를 요청하기 위해 객체 JSONP 필요하다 검증했다. 따라서 컨테이너 함수로 싸여 야합니다. http://www.jquery4u.com/json/ajaxjquery-getjson-simple/
: 는이 기사 느릅 나무는이 버그에 대한 짧은 항목이 발견 ...이 요청의 매개 변수와 함께 할 수 있어야하지만, 지금까지 내가 거의 아무것도 시도하지만 성공이 없었습니다Uncaught SyntaxError: Unexpected token :(in crome) Invalid Lable(in firefox) “invalid label” error can be fixed by passing the JSON data to the js callback
하지만 그가 말하는 것을 정말로 이해하지 못합니다.
무엇이 잘못 되었나요?
는 오류가 –
O3tmVI을 던져 정확하게 라인 표시합니다 O3tmVI은 (1 - 라인) JSON 객체를 반환으로, 1 – matthiasdv
당신이 할 경우 데이터 = $ .parseJSON (데이터) ? –