ligre
Junior Member

Posts: 2
Registered: 23-7-2009
Member Is Offline
|
|
phpmailer-fe with AJAX
Hi,
I was using a very simple mailsend php file to do an AJAX submit with my form, but I would like to use phpmailer-fe.
That php just created some HTML table that was both sent as email and displayed in the #sucess div, using something like this
| Code: | function showResponse() {
$('#contenido').hide();
$('#success').show('1500'); } |
Will the redirect page be displayed in that region too? Will it work with an ajax submit?
I am not too familiar with AJAX and PHP but I have some idea, I would appreciate a not-to-techy response.
|
|
|
andy.prevost
|
|
There is a feature in PHPMailer-FE for Flash forms that you can use in your Ajax scripting. You will have to create your own response messages in your
script though.
To use it, open the config file for your form, and look for this line:
$_POST['flash_sent'] = 'sent=OK';
whatever you replace 'sent=OK' with is what will get transferred back to your script.
Andy
|
|
|
littlerich
Junior Member

Posts: 2
Registered: 18-9-2009
Member Is Offline
|
|
Hi there,
I'm trying to accomplish the same thing but am struggling to understand your instructions (sorry, but I'm a relative noobie!)
I have successfully installed PHPMailer-FE and it works great except that I'd like the success/failure messages to reload in the current page. I'm
guessing it requires some Ajax expertise but I'm not yet a Jedi master!
I'd be really grateful if someone could give instructions on what I need to do. It's giving me sleepless nights!
Thanks,
Richard
|
|
|
andy.prevost
|
|
Users of Flash forms, like Ajax, are expecting a return code from the processing of the form. In Flash, that is fixed ... they are looking for
"sent=OK".
Set your Ajax listener to look for the same return, and that indicates the form processed properly and you can set your thank you message based on the
return code.
Andy
|
|
|
littlerich
Junior Member

Posts: 2
Registered: 18-9-2009
Member Is Offline
|
|
Hi Andy,
Thank you for your quick response! I actually got it to work by using the jquery.form.js plugin () and the following code:
<script type="text/javascript">
$(document).ready(function() {
$('#myForm').ajaxForm({
target: '#message',
// success identifies the function to invoke when the server response
// has been received; here we apply a fade-in effect to the new content
success: function() {
$('#message').fadeIn('slow');
}
});
});
</script>
This sent all the PHPMailer responses (success or fail) to the div named #message, just as I wanted.
Thanks for your help anyway.
Richard
|
|
|
andy.prevost
|
|
Thanks for letting me know.
Andy
|
|
|
Nancie
Newbie
Posts: 1
Registered: 18-12-2009
Member Is Offline
|
|
Thanks for this information..This is great..Cheers
|
|
|