我有一个CS:GO投注网站,当我尝试转到页面提取皮肤或类似的东西时,我验证了我不是一个使用recaptcha的机器人,我得到了这个错误:
Javascript错误: SyntaxError: JSON.parse: JSON数据的第1行第1列出现意外的数据结尾
代码如下:
function redeem(){
var code = $("#promocode").val();
$.ajax({
url:"/redeem?code="+code,
success:function(data){
try{
data = JSON.parse(data);
if(data.success){
bootbox.alert("Success! You've received "+data.credits+" credits.");
}else{
bootbox.alert(data.error);
}
}catch(err){
bootbox.alert("Javascript error: "+err);
}
},
error:function(err){
bootbox.alert("AJAX error: "+err);
}
});
}
下面是我的语法错误:
SyntaxError: Unexpected end of JSON input
at Object.parse (native)
at Object.$.ajax.success (http://www.gamesnodie.com/template/js/offers.js?v=106:249:29)
at j (http://www.gamesnodie.com/template/js/jquery-1.11.1.min.js:1:27244)
at Object.k.fireWith [as resolveWith] (http://www.gamesnodie.com/template/js/jquery-1.11.1.min.js:1:28057)
at x (http://www.gamesnodie.com/template/js/jquery-1.11.1.min.js:1:85993)
at XMLHttpRequest.b (http://www.gamesnodie.com/template/js/jquery-1.11.1.min.js:1:90047)
网络选项卡结果:http://prntscr.com/b1pao5
发布于 2018-10-26 03:56:52
我通过生成一个recaptcha密钥并将其添加到配置文件中解决了这个问题。在那之后,问题就解决了。
发布于 2016-08-20 02:42:17
请在您的问题中张贴您从服务器收到的JSON。
这个问题可能与格式错误的JSON有关,或者请求的头内容类型错误,实际上应该将JSON的"application/json“设置为" Content - Type”。
https://stackoverflow.com/questions/37101427
复制相似问题