The following Ajax call would send to PHP the parameters corresponding to the form that called the function:
var foo = "bar";
var bar = "foo";
function register(){
$.ajax({
method: "post",
url: "meu_script.php",
data: $("#form").serialize(),
});
}
And it would be accessible in PHP through id
s of HTML form components:
$campo = $_POST['id_campo'];
$senha = $_POST['id_senha'];
My question: what if instead of using a form, I wanted to pass the values of the variables foo
and bar
, what would be the data
parameter of my Ajax call?