Using ajax to send form data to php

后端 未结 3 784

I want to send form data from ajax to php. My ajax retrieves the form data but it doesnt send it i dont see anything wrong with the code maybe i need a much more professional he

3条回答
  •  深忆病人
    2021-01-22 21:17

    You can use serialize method on form, it will gather everything correct.

    $('#signup').live('click', function(){
    
       var that = $('form.check-user'),
       urls = that.attr('action'),
       methods = that.attr('method'),
       data = that.serialize();
    
    
       $.ajax(
    {
        url: urls,
        type: methods,
        data : data,
        beforeSend: function(response){alert('Sending');},
        success: function(response){ alert('success');},
        error: function(response){alert('failed');},
        complete: function(response){alert('finished');},
    }
    );
       return false;
       });
    

提交回复
热议问题