A question regarding the use of POST in the communication between Javascript / AJAX and PHP?

0

Well I'm working on a project that links JS to PHP through AJAX. To make this connection, I was using the GET method and I was requesting it like this: "seilaooque.php?valor1=x&valor2=y"

But now I'm thinking of moving everything to POST. But my question is even if in POST I can send the commands in this way "valor1=x&valor2=y" or I will have to send one value at a time through the method XMLHTTP.send()?

    
asked by anonymous 28.11.2017 / 14:18

1 answer

0

Using POST, your ajax looks like this:

$.ajax({
    url: 'suapage.php',
    type: 'POST',
    data: {var1: "var", var2: "var2", var3: "var3"}, //dados enviados via POST
    success: function(e) {

    }
});
    
28.11.2017 / 15:18