I've been working on this code I found somewhere. I use it to submit the Send to Friend form from a popup. It works but I can't get it to display the success message after it submits the form. Right now after it submits the form it just disappears. Maybe someone good at ajax can see what's the matter with it. Thanks
<script type="text/javascript">
//<![CDATA[
var formId = 'product_sendtofriend_form';
var sendfriendForm = new VarienForm(formId, false);
var postUrl = '<?php echo $this->getSendUrl() ?>';
function doAjax() {
if (sendfriendForm.validator.validate()) {
new Ajax.Updater(
{ success:'formSuccess' }, postUrl, {
method:'post',
asynchronous:true,
evalScripts:false,
onComplete:function(request, json) {
Element.hide(formId);
Element.show('formSuccess');
},
onLoading:function(request, json){
Element.show('formLoader');
},
parameters: $(formId).serialize(true),
}
);
}
}
new Event.observe(formId, 'submit', function(e){
e.stop();
doAjax();
});
//]]>
</script>