I'm passing an array on a POST request using jQuery, however I don't understand how to do the same with "vanilla" javascript. This is my jQuery:
// Request using jQuery
$.ajax({type:'POST',url:'insert-user.php',data: {myArray: myArray},
success:function(data_response){
console.log("jQuery, got data back, response: "+data_response);
}});
This is currently how I'm trying to do it with plain js:
// Request using plain js
var xmlhttp;
if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
console.log("JS, got data back, response: "+xmlhttp.responseText);
}
}
xmlhttp.open("POST","insert-user.php",true);
xmlhttp.send({myArray: myArray});