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

Asked

Viewed 67 times

0

Well I am working on a project that connects JS to PHP through AJAX. To make this connection was using the GET method and then made the request this way: "seilaooque.php?valor1=x&valor2=y"

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

  • GET and POST have no differences can be said, the difference is that GET is faster and POST is more secure

  • Yes Victor. But the parameter is the same?

  • Possible duplicate of https://answall.com/questions/106500/como-enviarum-dado-para-otha-pagina-php-pela-url

1 answer

0

Using the POST, your ajax would look like this:

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

    }
});
  • Thanks Prisley but in this case I’m not using Jquery. I’m only working with Javascript. But still thanks for the clarification.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.