I have one web application which I have been working for some time.I am sending data using HTTP POST request using AJAX technique.
I am using JavaScript like this:
var rdate=document.getElementById('rdate').value;
var Description=document.getElementById('description').value;
var urlstring="rdate="+rdate+"&Description="+Description;
oxhr.open("POST","http://localhost/info/php/store.php",false);
//checking for ready state change here
oxhr.send(urlstring);
But in database I see everything blank (no data but a row created)
Shouldn’t the urlstring contain variables? or what could be the possible mistake in JavaScript.
Any help is greatly appreciated.
Solution (to find the problem, because people aren’t physic): use a tool like Firebug / Fiddler2 / IE Developer Tools, or other, to see what is really sent, or if a request is even made.
While I won’t claim the following is an answer, the above manual string building in the post is … painful and not very robust. Here is a little useful function:
Use as:
This also correctly encodes the components so the query string does not become corruptued.
Happy coding.