Hi
I need to port a web form that connects to a remote service. The remote service can take up to 70 seconds to respond. Our standard web form is implemented using Javascript/AJAX/DHTML as follows
onsubmit: (assume the form is valid)
1) hide the form
2) display some sort of progress bar or busy animation
3) make an AJAX call to my remote service
4) if (remote service returned an error ) redisplay the form, along with the server error message
5) else display response from server.
I need to implement this in Drupal. For security reasons, we want to make the connection made from our Drupal server and not from the users web browser. I am having a lot of trouble. I based my code on the "ajax_example_submit_driven_ajax()" example. Maybe this was not a good example to start from?
Building the form and validating where easy, I can not get the ajax code to work the way I want. I do not know how to implement the "hide" in drupal so what I did was wrap the entire form, add my form elements. I added an extra "error box" element, and define the ajax. My idea was
a) when submit begins, disable the form elements (I could not figure out how to get this to work)
b) if I got an error back, enable the form elements, and display the remote server error in the "error box" element