What is GET and POST? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is GET and POST?

Can someone explain me what are GET and POST Request in Java Script and how they work?

12th Aug 2018, 3:08 PM
TAKENSUB MCPE-NETZWERK
TAKENSUB MCPE-NETZWERK - avatar
9 Answers
+ 3
If this helps because it will be very long to explain it here in detail. https://www.sololearn.com/learn/PHP/1841/
12th Aug 2018, 3:17 PM
Meet Mehta
Meet Mehta - avatar
+ 1
GET and POST are values for the "method" attribute of html form tag. It specifies how are data transferred from the form. GET shows variable values in the URL, while POST doesn't. You should never use GET for sending passwords or any other sensitive data. Disadventage of POST is, that the page cannot be bookmarked in your broswer.
12th Aug 2018, 3:15 PM
Jan Štěch
Jan Štěch - avatar
+ 1
In JavaScript you can use this. var body = document.getElementsByTagName("body"); body = body[0]; console.log(body.innerHTML);
12th Aug 2018, 3:19 PM
Jan Štěch
Jan Štěch - avatar
+ 1
You don't need to specify form's method when using JavaScript. You can get content of the input field using it's id as selector and get value of it's "value" variable.
12th Aug 2018, 3:24 PM
Jan Štěch
Jan Štěch - avatar
+ 1
Using php you can get the data using this: <form method=POST> <input type=text name="data" action=scriptCointainingPhpCodeBelow.php> </form> <?php echo $_POST['data']; ?>
12th Aug 2018, 3:30 PM
Jan Štěch
Jan Štěch - avatar
0
Thanks. Can you explain me how to get data ( like the inner HTML from a body tag ) from a server, return it and send it to another server? With none Api.
12th Aug 2018, 3:18 PM
TAKENSUB MCPE-NETZWERK
TAKENSUB MCPE-NETZWERK - avatar
0
Meet Mehta That's very helpfull for explaining. But how is the syntax in .js ?
12th Aug 2018, 3:19 PM
TAKENSUB MCPE-NETZWERK
TAKENSUB MCPE-NETZWERK - avatar
0
https://code.sololearn.com/Wx3iK51xuuGS/?ref=app Here I add a table cell with text submitted via HTML form using JavaScript.
12th Aug 2018, 3:21 PM
Jan Štěch
Jan Štěch - avatar
0
Jan Štěch Sorry for asking, but how include this code in an POST/GET Request?
12th Aug 2018, 3:22 PM
TAKENSUB MCPE-NETZWERK
TAKENSUB MCPE-NETZWERK - avatar