Load php content with jQuery AJAX

前端 未结 3 545
北荒
北荒 2021-01-22 03:24

My problem:

I have index.html:

Input:
3条回答
  •  無奈伤痛
    2021-01-22 03:36

    In your case you can use $.post()DOCS. If you gave your form an id="myForm" then you could load the return data into the form's parent in the callback as follows:

    $('#myForm').submit(function(e){
      e.preventDefault();
      $.post("toload.php", $("#myForm").serialize(), function(data) {
        $(this).parent().html(data);
      });
    });
    

提交回复
热议问题