AJAX Form is submitting to itself?

前端 未结 2 1044
别跟我提以往
别跟我提以往 2021-01-28 02:32

I don\'t know what is going on here tonight, but I can\'t seem to get AJAX working. When the form is submitted, it refreshes the page with the values in the URL. I\'m using a va

2条回答
  •  无人共我
    2021-01-28 02:47

    you need to cancel the default behaviour of submit button

    $(".button").click(function(e) {
                e.preventDefault();
                //rest of your code here
                var dataString = "fname=" + $("#firstName").val();
                alert(dataString);
                $.ajax({
    

提交回复
热议问题