I am trying to access the parameters passed in my AJAX request, but when I try to print them out in PHP, nothing shows up. I know emailData is defined and correct, so that is not the problem.
Here is my current code:
function sendEmail(){
var emailData = $('emailForm').serialize(true);
new Ajax.Request("php/email.php",
{
method : "get",
parameters : emailData,
onFailure : ajaxFailure,
onException : ajaxFailure
}
);}
and in email.php
print_r($_GET);
EDIT
When I check to see if emailData is defined with an alert or console.log, I get the correct values I want, in the correct format for ajax parameters according to http://www.prototypejs.org/api/form/serialize.
2nd EDIT
Seems to work now. I haven't modified the code at all, but it seems to work now.
You have no onSuccess:
value. You're only checking for errors and exceptions.
Do something like:
function sendEmail(){
var emailData = $('emailForm').serialize(true);
new Ajax.Request("php/email.php",
{
method : "get",
parameters : emailData,
onFailure : ajaxFailure,
onException : ajaxFailure,
onSuccess : function() { alert("success!"); }
}
);}