Model binding with jquery ajax serialize not working

后端 未结 2 619
不思量自难忘°
不思量自难忘° 2021-02-06 03:32

I have the following model:

public class RegisterUseraccount
{
    [Required]
    [DataType(DataType.EmailAddress)]
    [Display(Name = \"E-Mail-Adresse\")]
             


        
2条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-06 03:46

    remove contentType: 'application/json', and modify it to better (from my perspective)

    $('#registerUseraccountForm').submit(function () {
        if ($(this).valid()) {
            $.ajax({
                url: this.action,
                type: this.method,
                data: $(this).serialize(),
                beforeSend: function () {
    
                },
                complete: function () {
    
                },
                ...
    

提交回复
热议问题