Couldn't find this anywhere, maybe someone knows or can make a suggestion.
I had a form with lots of <inputs>, I wanted to send that form with jQuery $.ajax functionality, so I did $('#myform').serialize() and send this as json.
Now my form is more advanced and has HTML5 data- attributes, that I want to send too, but .serialize() doesn't see them.
I tried putting them in <form> tag, <input> tags - nothing works.
What is the best practice to grab them and send with all the form data? I know about .serializeArray(), but how do I get all of the data- attributes that my <form> tag has attached serialized?
data-foo="bar"to get mapped tofoo=bar? Also, is there any reason they can't go intohiddeninput tags?$('#myform').serialize()and the string would have input values anddata-attribute values serialized and escaped. It could be a custom function.