I read about GET and POST on the internet and I am quite confused about it.
I understand most of it but, I have few confusion like Should I use GET method to get (retrieve) the data from action page, we cannot change server data sing it (edit, delete, update) while post is used to just post the data on the server and we can do (edit, delete, update) with this.
Like I have following example I am confused on how to make it using POST method? And I have no parameter to pass in the url.
I also see, I cannot make it asynchronous.
xmlhttp = new XMLHttpRequest();
var url = "/TinyEditor/XML/PreviewBody.xml"
xmlhttp.open("GET", url, false);
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send();
// alert(xmlhttp);
var xmlDoc;
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
xmlDoc = xmlhttp.responseXML;
// alert(xmlDoc);
}
}
When i use POST method for the above code i am getting error,
<title>The HTTP verb POST used to access path '/TinyEditor/XML/PreviewBody.xml' is not allowed
Why so?
then just make post_variable like this
remember to encode values with encodeURIComponent(value)
so for example your string would look like this
I hope this helps
I recommend you to start using jQuery its lightweight and it will be much easier to use then your custom made scripts. So basically if you use jQuery you can do it this way
and that is all, you don’t have to worry about anything, about browser version, browser type, or similar things.