Post form with Ajax and jQuery

前端 未结 3 1621
-上瘾入骨i
-上瘾入骨i 2021-01-27 10:39

Start learning Ajax (and jQuery), I encounter the issue with post form data, which I could not resolve myself.

First, here is the simple example where I collect data, po

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-27 11:15

    You're going to need a success callback, which I'll assume will be some HTML...

    $(document).ready(function(){ 
        $("#myButton").click(function() { 
            $.ajax({
            cache: false,
            type: 'POST',
            url: 'test.php',
            data: $("#myForm").serialize(),
            success: function(response) {
                $("#someElement").html(response);
            }
            });
        }); 
    });
    

提交回复
热议问题