user8244016 user8244016 - 2 months ago 15
Ajax Question

JavaScript - How does AJAX data request appear in the url?

when sending

AJAX
request from client side to server side (if I'm not wrong) we often send data like this :

var postData={name: John, psd: 123 , description : "student"};
var xhttp = new XMLHttpRequest();
xhttp.open("POST","http://localhost:8080/user", false);
xhttp.setRequestHeader("Content-type", "application/json-application");
xhttp.send(postData);


I'm not sure how does the sent data
postData
appear in the url to the server. I'll be glad if someone can help me or guide me to some materials or articles.

Answer Source

I guess your confusion is related to a misconception about POST requests. POST requests can post data to servers. This data (thankfully) does not have to be in the url as query string. Indeed, that's how web gets secured by HTTPS. So data could be sent to a server in a POST request in two separate ways: query string and post data. I hope that helps.