passing array of objects from js to rails

前端 未结 2 987
刺人心
刺人心 2020-12-31 15:04

I am trying to pass an array of objects from js to rails

data.test = [{test: \'asdas\'}]

$.ajax({
  url: \'evaluate.json\',
  data: data,
  success: functio         


        
2条回答
  •  失恋的感觉
    2020-12-31 15:53

    Try this:

    data.test = [{test: 'asdas'}]
    
    $.ajax({
      url: 'evaluate.json',
      data: JSON.stringify(data),  // Explicit JSON serialization
      contentType: 'application/json',  // Overwrite the default content type: application/x-www-form-urlencoded
      success: function(data){
      },
      dataType : "json"
    });
    

提交回复
热议问题