ajax post within jquery onclick

前端 未结 4 1771
伪装坚强ぢ
伪装坚强ぢ 2021-01-11 09:01

I have a button which calls a modal box to fade into the screen saying a value posted from the button then fade off, this works fine using jquery, but I also want on the sam

4条回答
  •  粉色の甜心
    2021-01-11 09:45

    You have an error in your ajax definitions. It should be:

    $.ajax
    ({ 
        url: 'reserbook.php',
        data: "book_id="+book_id,
        type: 'post',
        success: function()
        {
            $('.modal-box').text(result).fadeIn(700, function() 
            {
                setTimeout(function() 
                {
                    $('.modal-box').fadeOut();
                }, 2000);
            });
        }
    });
    

提交回复
热议问题