serializeArray
creates an array (not a "json array" -- there is no such thing); you can test this yourself with console.log($("#myform").serializeArray())
. On the other hand, serialize
creates a query string that's meant to be part of an HTTP request. Both representations are equivalent in the sense that using appropriate code you can convert one to the other without any ambiguity.
The reason for both versions being available is that serialize
is more convenient when you just want to make an HTTP request (just put the result in the query string) while serializeArray
is more convenient if you want to process the results yourself.
jQuery's AJAX methods don't care if you give them one or the other because they detect the type of the parameter and convert it to a query string if it's not one already, so by the point the request is made outside observers cannot tell what was the original format of the parameters.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…