Rails Active Model Serializers与Ajax冲突?

时间:2015-08-27 02:34:52

标签: ruby-on-rails ajax active-model-serializers

当我使用gem "active_model_serializers"时,我的所有Ajax都无法正常工作,我的代码如下:

$(document).on('change','#brand_id_dropdown', function () {
   var request = "/beacons/find_beacon_uuid_given_brand_id?brand_id=" 
        + $('#brand_id_dropdown').val();

    var aj = $.ajax({
        url: request,
        type: 'get',
        data: $(this).serialize()
    }).done(function (data) {
         change_uuids(data);//modify the majors' dropdown
    }).fail(function (data) {
         console.log('AJAX request has FAILED');
    });
});

我尝试过改为

data: { get_param: 'value' }, 
dataType: 'json'

仍然冲突,每当我使用gem serial和启动rails服务器时,所有Ajax都会失败。我该如何解决?

0 个答案:

没有答案