I want to create a function so I can send $_POST using ajax. I made code like this but it is not working.
function send(variable, value){
var e = value;
bar = variable;
$.ajax({
type: 'POST',
url: "vote.php",
data: {bar:e},
success:function(){
console.log(e);
}
});
}
I can see the problem is that data{bar} is not getting the variable value.
How can I make it so that I can get $_POST['dog'] = corgi
when I write the function
send(dog, corgi)
and $_POST['cat'] = bengal
when I write
send(cat, bengal)