I have form with different count of fields. User can input html tags and I need to escape them. I need itterate over all input elements and apply encodeURIComponent to each of element value and than use $.param() to send data. How to do that? Or might be somebody know more elegant solution?
Thanks!
Usually,
$(form).serialize()is enough. If that doesn’t work, you can first use$(form).serializeArray()to encode form elements as an array of names and values, then applyencodeURIComponentto some fields that need to be escaped. At last, call$.param().BTW, as a matter of fact,
serializeis composed of$.paramand$(form).serializeArray