简体   繁体   English

tomcat服务器上的$ .ajax意外标记错误(GWT)

[英]$.ajax unexpected token error on tomcat server (GWT)

we are currently working on a GWT Project and ran into an unexpected token error called by .parseJSON in this function after compiling and running the project on a tomcat server. 我们正在开发一个GWT项目,并在tomcat服务器上编译和运行项目后遇到了由此函数调用的.parseJSON意外的令牌错误。 In dev mode on eclipse this worked fine: 在Eclipse上的开发模式下,这很好用:

$.ajax({
  url: "index/sequences/seq.json",
  datatype: "json",
  }).success(function(data) {
var data = jQuery.parseJSON(data);
  });

This is the json; 这是json; validated by jsonlint 由jsonlint验证

{"cont":[{"values":"left arm up,turn left,sit","name":"greet&go"},{"values":"turn left,turn right,walk back","name":"strange moves"},{"values":"kick right,turn right, right arm up","name":"right moves"},{"values":"kick right,walk,sit","name":"sequnece 4"},{"values":"sit,stand,kick left","name":"up&down"},{"values":"stand,turn right,sit","name":"testin"},{"values":"turn left,kick right","name":"kickit!"},{"values":"turn right,look up,left arm out,walk","name":"greet the audience"}]}

After some debugging i realized, that the parseJSON is called two times; 经过一些调试我意识到,parseJSON被调用了两次; first time with no errors, right data and all, second time with empty data, what calls the error. 第一次没有错误,正确的数据和所有,第二次使用空数据,什么调用错误。

Any help welcome! 欢迎任何帮助! THX! 谢谢!

datatype should be dataType , and if you are supplying the dataType parameter (or passing the appropriate Content-Type: application/json header ), you don't need to parse the json. datatype应该是dataType ,如果要提供dataType参数(或传递相应的Content-Type: application/json header ),则不需要解析json。

$.ajax({
  url: "index/sequences/seq.json",
  dataType: "json"
}).success(function(data) {
  console.log(data);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM