jQuery在javascript中序列化

I'd want to know if there is something in javascript that can do the same job as .serialize() does. I'll need to use it someform.onsubmit = funct... or <form onsubmit=".... I need just to get all the data in that form (just as jQuery does) as a string.

Thank you in advance

I think the closest thing would be to use FormData. Something like:

document.querySelector('form').addEventListener('submit', function (e) {
    e.preventDefault();

    xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4 && xhr.status == 200) {
            console.log(xhr.responseText);
        }
    }
    xhr.open("POST", "/echo/json");
    xhr.send(new FormData(this));
});

This is arguably even simpler than calling .serialize on the form collection, but note that you can't inspect what is inside the FormData object apparently. This is also relatively new, so not so cross-browser compatible.