views:

68

answers:

2

This JSON post works, but if I start clicking them quickly, they start returning 500 errors. I'm guessing this is because they're not queueing correctly, and they fall apart when they can't go out one by one. Is there a way to queue this in JSON?

Here's my button in HAML :

= f.check_box :has_sticker, :style => 'width: 20px;', :class => "orgs_deals_admin_save"

And here's my jQuery :

$('.orgs_deals_admin_save').live('click', function() {
    var button = $(this);
    var form = button.closest('form');
    var dataString = form.serialize();
    $.ajax({
        url: form.attr('action') + '.json',
        dataType: 'json',
        type: 'POST',
        data: dataString,
        success: function(data) {
        }
    });
});
+1  A: 

500 is server error problem code, so i suppose that there is some problem with processing your script on the server side

Dobiatowski
+1  A: 

This is because per default asynchronous is set to true. If you want them to be processed in the exact same order you sent them, set asynchronous to false.

Anders
Thanks Anders. You are a genius. I imagine you code robots that wil eventually take over the world for a living.
Trip
@Trip, haha, easy with the jamaican now. But you should definitely be looking into why it's failing on the server side.
Anders
@Anders, Wait - what were we talking about? .. oh yah..I set it to async: false, and it seemed to work as it wouldn't allow me to post until another went out. Which was all I needed for it to succeed.
Trip