Hi all,
I have used 'Get' a couple of times before to call a php page and then in the php page I have simply used $_GET['the get variable name'].
But I don't know how to capture the Post parameter in my php code.
so I have:
AjaxUpdater.Update("POST", "process.php", postData, Display.display);
Display.display is my callback function.
i used $_POST['postData'] in my php to capture the data but no hope.
would someone please help me???
Thanks
Post Ajax call to a php page
Moderator: General Moderators
Re: Post Ajax call to a php page
Depends what the postData is. It probably is a hash like {a:123, b:234} or a string like "a=123&b=234", in which case you should be using $_POST["a"] and $_POST["b"].
Re: Post Ajax call to a php page
hi thanks for your reply.
postData is simply a string value. say postData='hello'
when i post it to my ajax request is like this:
...
this.request.open("POST", "process.php", true);
this.request.send(postData);
...
but as you said in process.php i have :
$res = $_POST['postData'];
but $res is not set.
postData is simply a string value. say postData='hello'
when i post it to my ajax request is like this:
...
this.request.open("POST", "process.php", true);
this.request.send(postData);
...
but as you said in process.php i have :
$res = $_POST['postData'];
but $res is not set.
Re: Post Ajax call to a php page
Unless you want to try reading the raw input
then I'd suggest changing the POSTed data to something in the key=value form.
Code: Select all
$data = file_get_contents("php://stdin");Re: Post Ajax call to a php page
Thanks for your reply. but I dont understand your solution.
I just simply want to get access the posted value from client side to server side through an ajax call.
if you please explain more how this function (file_get_contents) would be useful in ajax call?!
thanks
I just simply want to get access the posted value from client side to server side through an ajax call.
if you please explain more how this function (file_get_contents) would be useful in ajax call?!
thanks
Re: Post Ajax call to a php page
I hope I don't have to explain the concept of standard input...
POST data comes in to a place called php://stdin. If it looks like key=value&key=value&... then PHP automatically parses it into the $_POST array.
If it does not then you have to get the data yourself: a function like file_get_contents can read in everything. Then you do whatever you want with it.
POST data comes in to a place called php://stdin. If it looks like key=value&key=value&... then PHP automatically parses it into the $_POST array.
If it does not then you have to get the data yourself: a function like file_get_contents can read in everything. Then you do whatever you want with it.