Search code examples
javascriptformsserializationprototypejs

How safe is it to use prototypes Form.serialize()?


Somehow, when using Prototype's Form.serialize() to submit complex forms, I always feel a bit unsure as to whether this will work in all cases.

Possible issues I worry about are quote/string escaping issues, or perhaps the submission of unusual character codes, anything that could mess up the process.

So the question is:

Is it safe (on the client side) to collect all the data from a form using Prototype and then send it to the server via AJAX or are there any browsers that are known to have troubles sending forms this way — or perhaps, lack of support for it?


Solution

  • While no browser that I know internally uses Javascript to submit a form, the exact details of how a form should be submitted are very well documented.

    It is quite possible to write form submission code in Javascript that follows the protocol exactly. On the other hand, an experienced coder may miss some of the edge cases -- like disabled checkbox controls.

    I can't speak for the prototype library since I've never used it, but if there is a form that does not submit properly, or a server that does not take a submitted form, then it should be submitted as a bug report.