MultiJson :: DecodeError when sending an ajax request to Rails

I have the following code:

$.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(){ } }); 

The following exception was sent when sending this request:

MultiJson :: DecodeError

unexpected token in 'checked% 5Ba% 5d = 1'

What is it?

+4
source share
1 answer

I have found a solution. Now it worked (see 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(){ } }); 
+6
source

All Articles