Jquery serialize() is empty

后端 未结 2 1513
离开以前
离开以前 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:01
    Use serialize() method when form is submit.
    
    check this fiddle https://jsfiddle.net/6o6htoh1/1/
    
    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题