I didn't find an equivalent of .serialize() for vanilla javascript, so I rolled my own.
function uzim_vred(phpdoc,parent_id){
var name = "";
var val = "";
var str = phpdoc+"?,";
var len = ($("#"+parent_id+" [name]").length);
var i = 0;
$("#"+parent_id+" [name]").each(function(){
i++;
name = $(this).attr('name');
val = $(this).val();
str += name+"="+val;
if(i<len){
str += "&,"
}
});
i = 0;
var elems = str.split(",");
str = "";
while(i<=len){
str += elems[i];
i++
}
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if((document.getElementById("raport")!=undefined || document.getElementById("raport")!=null) && this.readyState == 4 && this.status == 200){
document.getElementById("raport").innerHTML = this.responseText;
}
};
xhttp.open("GET", str, false);
xhttp.send();
}
How to envoke it:
<button type="button" onclick="uzim_vred('yourPHPscript.php',$(this).parent().attr('id'))">Send</button>
First argument is a path to and name of php script, second is used for id of form element from whom you want to "serialize" values.