odi*_*apc 4 ajax jquery ruby-on-rails
我有以下代码:
$.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(){
}
});
Run Code Online (Sandbox Code Playgroud)
发送此请求时抛出以下异常:
MultiJson :: DecodeError
"已检查%5Ba%5D = 1"处的意外令牌
这是什么?
我找到了解决方案.它现在有效(参见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(){
}
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
479 次 |
最近记录: |