How to cacth symphonys form success response via ajax?
This is an open discussion with 5 replies, filed under General.
Search
To what event URL are you posting? Is the event attached to the relevant page? Your AJAX request is expecting an XML response, so is the page's type set to XML
?
Your id
s don't seem to match either, or I'm missing something.
I´m still having a problem with this, so far i think the problem is that the form does not have a action atribute set, so the jquery plugin does not work, here is how i´m doing it:
Form:
<h2 class="h2_dark">Entre em contato</h2> <p class="p_dark">Tire suas dúvidas, elogie ou critique, não tem problema, o importante é nos dizer o que pensa.</p> <div id="form_conteiner"> <form method="post" action="" enctype="multipart/form-data" id="form_contact"> <input name="MAX_FILE_SIZE" type="hidden" value="5242880" /> <div class="form_input"> <label>Nome *:</label> <input name="fields[nome]" type="text" class="input" /> </div> <div class="form_input"> <label>Email</label> <input name="fields[email]" type="text" class="input" /> </div> <div class="form_input"> <label>Empresa</label> <input name="fields[empresa]" type="text" class="input" /> </div> <div class="form_input"> <label>Telefone</label> <input name="fields[telefone]" type="text" class="input" /> </div> <div class="form_input"> <label>Menssagem</label> <textarea name="fields[menssagem]" rows="15" cols="50" class="textarea" ></textarea> </div> <div class="error_div"><ol></ol></div> <br clear="all"/> <div class="form_input"> <input name="action[form-contato]" type="submit" value="" class="button" /> </div> <input name="redirect" type="hidden" value="http://layoutz.com.br/pagina/sucesso/" /> </form> </div> <div id="form_waiting"></div> <div id="form_response"></div>
Javascript:
$('#form_contact').ajaxForm({ // target identifies the element(s) to update with the server response target: '#form_response', resetForm: true, // override for form's 'action' attribute beforeSerialize: function() { $('#form_conteiner').html('<div id="form_wait"><span>Enviando seu email, por favor aguarde um momento!!!</span><br/><br/><img class="loading_gif" src="imagens/loading.gif" width="200"/></div>'); } , success: function() { $('#form_conteiner').hide('fast'); $('#form_response').show('slow'); setTimeout(function(){ window.location.reload(true); }, 6000); } });
The jquery plugin i´m using is this:
http://jquery.malsup.com/form/
What seems to happen is that when i submit the form, the page still reloads vary fast for just a split second, and nothing is returned end no emails are sent, i must mation that i´m using "Email Template Manager" with my forms.
Can anybody help?
see what happens if you remove enctype="multipart/form-data"
What seems to happen is that when i submit the form, the page still reloads vary fast for just a split second, and nothing is returned end no emails are sent, i must mation that i´m using "Email Template Manager" with my forms.
This happens when there's an error in your javascript OR you're not returning false for the submit function. Since you're using a plugin, and many people use it, it's probably not the plugin.
I can't see any obvious errors in your javascript, but you should use the Inspect option in the browser. Sometimes errors don't show up until you click submit (at which point the error is probably caused by an invalid json response).
To get around this, do this:
$('#form_contact').submit(function() { return false; }
This should still let your ajax request execute without actually POST'ing to the current page. If no action is specified on a form, it will POST to the current page, return false should take care of it.
Create an account or sign in to comment.
In my website i use ajax to fech pages, and to control de contact form submit, i´m using a jquery plugin for the form submition, but can´t get the success respose to work.
the plugin is this: http://jquery.malsup.com/form/
And my code looks like this:
and my form code:
Does anybody have a idea about this?