How to use jQuery .ajax to my form's action

前端 未结 5 2319
你的背包
你的背包 2021-02-08 12:54

I changed my coding style for php and jQuery, but my Registration

$(\"#reg_form_company\").bind(\"submit\", function() {
    $.fancybox.showActivity();
    $.aj         


        
5条回答
  •  温柔的废话
    2021-02-08 12:57

    You must intercept the click/submit event for your form and refer the form as shown bellow:

     $("#myForm").submit(function(){
        var $form = $(this);
    
        $.ajax({
         type     : "POST",
         cache    : false,
         url      : $form.attr('action'),
         data     : $form.serializeArray(),
         success  : function(data) {
             $(".printArea").empty().append(data).css('visibility','visible');
         }
        });
     })
    

    And add an id to your form like:

    [...]

提交回复
热议问题