I have an ajax contact form that uses an ajaxSubmitButton() to submit the form, it then returns the result in a lightbox. The problem is that if there are errors (which are passed back and displayed in the lightbox)the user needs to be able to correct them and submit the form again, however it seems it will only let you submit the form once via ajax.
Is there something I’m doing wrong? Any help is appreciated.
And for the sake of testing site/ajaxcontact just returns the time, I have removed everything other than that to try and get it to work. It returns the time the first time but then doesn’t update when clicked again.
Just my curiosity? Is it a typo there in the last line? Why you are using CHtml.form() (which begins form) in place of CHtml.endForm()?
I’m pretty sure that this will not change anything nor bring you closer to solving your problem. But since I had a really big problems (especially in IE) because of not closing form tag properly, I wanted to point this out to you.
And even more curiosity! :] Why you are using PHP’s opening an closing tags in each line? Wouldn’t be easier for you (less typing) to write something like this:
In my opinion solution is only bad, when it is not working! :]
Just kidding! Of course, that clean, readable code and coding following best practices is always better than just writing a junk code. But on the other hand, since perfection is an evil enemy of good (a bad attempt to translate Polish proverb into English! :}), then you shouldn’t waste your time for an endless looking for a cleaner solution, if the one is working and satisfy you.
I had similar issue when implement a ‘add-to-cart’ button which use ajax request backend add2cart , when I click the ‘add-to-cart’ several times, the post data (quantity and product_id) looks like has been sent several times but each time the quantity over added to the previous request.It’s really headache to figureout the reason since seems the code is correct.
Finally, I solved the issue by use $(’#add_to_cart’).unbind(‘click’); before