글

라벨이 Unexpected end of JSON input인 게시물 표시

[Solved] jQuery - parsererror SyntaxError: Unexpected end of JSON input

 Unexpected end of JSON input jQuery.ajax를 사용하다가 위와 같은 오류를 접했다. parameter가 잘못된거 같은데 잠시 삽질을 했다. [Error Message] SyntaxError: Unexpected end of JSON input at parse ([anonymous]) at jquery.min.js:2 at l (jquery.min.js:2) at XMLHttpRequest.[anonymous] (jquery.min.js:2) [Error Code] $.ajax({ url: 'https://www.example.com/api', method: 'POST', data: $.param(param), dataType: 'json', contentType : 'application/json', success: function (data) { console.log(data); }, error: function (_e, _x, _s) { console.log(_e, _x, _s); } ); [Solved Code] $.ajax({ url: 'https://www.example.com/api', method: 'POST', data: JSON.stringify(param) , dataType: 'json', contentType : 'application/json', success: function (data) { console.log(data); }, error: function (_e, _x, _s) { console.log(_e, _x, _s); } ); 너무 오랜만에 타이핑을 쳐서 사용했더니 이런 낭패가 생기는구나.