Post form with Ajax and jQuery

前端 未结 3 1622
-上瘾入骨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:09

    Try this.

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

提交回复
热议问题