简体   繁体   中英

jQuery Ajax not working on second occurence

I can't fathom what's causing this error, I've tried everything I can think of to fix it. I have two different submit buttons, designed to fire some Ajax and post data, on my page. One works and fires perfectly. The second never POST s anything.

Can anyone see where I might have gone wrong?

$('.delete').submit( function(event) {

    event.preventDefault(); 
    $(this).children('input[type=\"submit\"]').prop('disabled',true);
    alert("Click detected!");

    $.ajax({
        url: 'scripts/deleteWork.php',
        data: slideID,
        type: 'POST',
        mode: 'abort',
        success: function(){
            $('#newOrder-1').fadeOut('fast');
        },
        error: function(){
            $(this).children('input[type=\"submit\"]').prop('disabled',false);
        }
    });
    return false;
});

I've tried removing the first occurrence, in case it was causing the problem by clashing somehow. I've checked and re-checked my syntax. The alert fires fine... just no sign of a POST in Firebug. I don't understand it!

Thanks for any help.

*smacks forehead*

I needed to add the following line:

var slideID = $('#slideID').val();

Thanks Aaron W. and thecodeparadox.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM