0

When I use gem "active_model_serializers", my all Ajax can't work, my code like following:

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

I tried change to

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

still conflict, whenever I gem serializer and start rails server, all Ajax fail. how can I fix that?

John
  • 387
  • 5
  • 17

1 Answers1

0

I can't comment because I don't have enough rep. But you need to supply a little more information.

What's the failure message in the rails server logs? Check the rails server output and copy paste the errors into your question. Also, open your browser console and paste the "console" or "network" errors (in chrome: OPTION+CMD+I to show console). Lastly, throw a debugger; statement into your ajax call and play around with the variables.

daino3
  • 4,386
  • 37
  • 48
  • rails server logs has no error messages, and console I use chrome, headersSize: 992 httpVersion: "HTTP/1.1" redirectURL: "" status: 304 statusText: "Not Modified", is this what you mean? – John Aug 27 '15 at 06:30
  • Yes, thank you. When you put a `debugger` in the on(change) event... does the breakpoint work? I'm wondering if the ajax request is even getting fired. – daino3 Aug 27 '15 at 14:20