4

我有以下代码:

$.ajax({
  headers: {'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content'), 'Content-Type': 'application/json; charset=utf-8'},
  url:'/monitoring',
  type:'POST',
  data: {checked:{a:1}},
  dataType: 'json',
  success: function(){
  }
});

发送此请求时引发以下异常:

MultiJson::DecodeError

'checked%5Ba%5D=1'处的意外令牌

这是什么?

4

1 回答 1

6

我找到了解决方案。它现在可以工作了(参见 Content-Type):

$.ajax({
  headers: {'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content'), 'Content-Type': 'application/x-www-form-urlencoded'},
  url:'/monitoring',
  type:'POST',
  data: {checked:{a:1}},
  dataType: 'json',
  success: function(){
  }
});
于 2012-06-08T06:17:51.650 回答