By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,011 Members | 2,968 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,011 IT Pros & Developers. It's quick & easy.

Ajax POST and GET which one i should use.

P: 62
Hi,
I have problem about ajax GET method.
I use ajax to send mail and i use method GET.
when i send alittle bit data it's work good but once i
type so much in the form and send...i don't get any mail .
i tried many time but it did not help except i will not type so much
then main will be sent...why ?

do i haver to change methos to POST?
what is different and how ?


I always appreciate every help
alex
Jan 17 '08 #1
Share this Question
Share on Google+
11 Replies


Markus
Expert 5K+
P: 6,050
Hi,
I have problem about ajax GET method.
I use ajax to send mail and i use method GET.
when i send alittle bit data it's work good but once i
type so much in the form and send...i don't get any mail .
i tried many time but it did not help except i will not type so much
then main will be sent...why ?

do i haver to change methos to POST?
what is different and how ?


I always appreciate every help
alex
GET has restrictions on how much data can be passed through the URL - i'm not sure how large the restrictions are, but there definitely is some.

POST, however, does not have restrictions on the amount of data sent.. i think; either way it's much, much larger than GET.

To change to POST isn't hard and sounds like what you need!

Best of luck.
Jan 17 '08 #2

acoder
Expert Mod 15k+
P: 16,027
See this POST example.
Jan 18 '08 #3

P: 62
Thak you so much i will try..:-)
Jan 18 '08 #4

P: 62
Actually it's not so hard to change method from GET to be POST in ajax file...
But how about PHP? i see it not work at all...
could u please give me a example easiest php send mail which get from POST ajax in this cast ?

Thank you so much
Alex


here is what i do but i did not get any mail at all.
[php]<?php

$recipient = 'mymail@hotmail.com';
$subject = $_POST['subject']
$from = $_POST['from']
$email = $_POST['email']
$text = $_POST['text']
$ip = $_SERVER['REMOTE_ADDR'];

$msg = "From: $from\n Email: $email \n IP Adrress :$ip \n\n Message: $text";
mail($recipient, $subject, $msg);

?>[/php]
Jan 18 '08 #5

acoder
Expert Mod 15k+
P: 16,027
First make sure it's working without Ajax.
Jan 18 '08 #6

P: 62
yes..i check it and everything is work good if i use GET method..
But i need to use POST method but it not work here.
Here is additional thing that i want to tell you

var params = "$sender=" + encodeURIComponent(document.iform.sender.value)+
"&$email=" + encodeURIComponent(document.iform.email.value)+
"&$subject=" + encodeURIComponent(document.iform.subject.value)+
"&$text=" + encodeURIComponent(document.iform.text.value);

The params varialable be sent by

xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttp.send(params)

But what should i do with PHP `

best regards
Alex
Jan 18 '08 #7

100+
P: 130
Actually it's not so hard to change method from GET to be POST in ajax file...
But how about PHP? i see it not work at all...
could u please give me a example easiest php send mail which get from POST ajax in this cast ?

Thank you so much
Alex


here is what i do but i did not get any mail at all.
[php]<?php

$recipient = 'mymail@hotmail.com';
$subject = $_POST['subject']
$from = $_POST['from']
$email = $_POST['email']
$text = $_POST['text']
$ip = $_SERVER['REMOTE_ADDR'];

$msg = "From: $from\n Email: $email \n IP Adrress :$ip \n\n Message: $text";
mail($recipient, $subject, $msg);

?>[/php]
if you copy paste this code u missing ";"

Expand|Select|Wrap|Line Numbers
  1. $subject = $_POST['subject']
  2.    $from = $_POST['from']
  3.    $email = $_POST['email']
  4.    $text = $_POST['text']
check your logs to see the error u getting and post it here
Jan 18 '08 #8

P: 62
[quote=paitoon]Actually it's not so hard to change method from GET to be POST in ajax file...
But how about PHP? i see it not work at all...
could u please give me a example easiest php send mail which get from POST ajax in this cast ?

Thank you so much
Alex


here is what i do but i did not get any mail at all.
<?php
$params = $_POST[params];
$recipient = 'geisha_hi-so@hotmail.com,ffffftmnsr@mahidol.ac.th';
$subject = $_SERVER['subject'];
$from = $_SERVER['from'];
$email = $_SERVER['email'];
$text = $_SERVER['text'];
$ip = $_SERVER['REMOTE_ADDR'];

$msg = "From: $from\n Email: $email \n IP Adrress :$ip \n\n Message: $text";
mail($recipient, $subject, $msg);

?>
Jan 18 '08 #9

P: 62
I did everything but alll is does not help
i think i have to do something with php..
i send variable params from javascrip which contents

var params = "$sender=" + encodeURIComponent(document.iform.sender.value)+
"&$email=" + encodeURIComponent(document.iform.email.value)+
"&$subject=" + encodeURIComponent(document.iform.subject.value)+
"&$text=" + encodeURIComponent(document.iform.text.value);

and i have to do something with variable params in PHP
but i don't know how .....?
i guess or what do you think ?

thanks
Alex
Jan 18 '08 #10

P: 62
yesssssssssssssssss!! i got it
all is because i did not put the $params = $_POST['params']; in PHP
But now everything is work great :-)

thank you everybody here
Alex
Jan 18 '08 #11

acoder
Expert Mod 15k+
P: 16,027
I did think there must've been a problem in your PHP. Glad you got it working.
Jan 19 '08 #12

Post your reply

Sign in to post your reply or Sign up for a free account.