how to post form data in ajax way and without jquery or other libraries.
I want to define a ajaxForm function, which could serialize the form data and AJAX post, and then callback by javascript.
If I has form below:
<form action="url" method="POST">
<table>
<tr><td>label...</td><td><input name="input1" type="text"/></td></tr>
<tr><td>label...</td><td><input name="input2" type="checkbox"/></td></tr>
<tr><td>label...</td><td><select name="input3"><options....></select></td></tr>
</table>
</form>
and I got the form element by javascript, and then I pass the form element and callback function to ajaxForm(form, callback) function.
Any one could give a example of that ? Thanks a lot....
update : My most problem is how to serialize form data ?
update again: Thanks for all your response. Problem resolved.
I have migrated the jquery form plugin to pure javascript. and I am glad to share it with you guys.
https://github.com/guileen/ajaxform.js
button.onclick = function(){
ajaxForm(form, function(xmlhttp){
alert(xmlhttp.status);
alert(xmlhttp.responseText);
});
}