Jquery serialize() is empty

后端 未结 2 1487
离开以前
离开以前 2021-01-25 20:31

I\'ve a contact form that sends data to a PHP script via AJAX. It\'s pretty basic but I can\'t get input values with serialize. The form id is correct, i obtain the input name b

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-25 21:10

    You have a syntax mistake when you use the jquery selector to a jquery object, when you select your form you must use it lately like this:

    var form = $('#contact-form'); //and then use it directly in the ajax call like this
    form.serialize(); // not $(form).serialize()
    

    Here is your fiddle updated https://jsfiddle.net/ingemi/kbpnmptw/ you must use serialize directly in the ajax call

提交回复
热议问题