I'm trying to send some data in my server asynchronously using AJAX.
I need to send the data using the POST
method because the data sent are quite
many characters and by using GET
the created URL will be too big. Well that's not a problem, but for aesthetically reasons I would rather have small URLs. In order to do so I used the solution (question) explained here.
My Javascript code sending the data is:
var code = "code=" + document.getElementById("code_area").value;
xmlhttp.open("POST", "run_code.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send(code);
The above code is executed when I click a button, but then the URL changes to this: localhost/code.php?code=datadatadatadatadatadatadatadatadatadatadatadatadatadata
which seems is no different of using GET
instead (my URL has become quite big). I used POST
, not GET
but still data seems to get transmitted by the URL. Any ideas why is this happening?