Ok, I think I figured it out. I may have had it close to right before,
but was just missing a } or something.

Here is an example:

function confirmStep(step_num,goto_step,button_msg){
        var error_msg = validateForm(step_num);

        var opt = {
                // Send the data
                parameters: $(step_num).serialize(),
                // Use asynchronous
                asynchronous: true,
                // Handle successful response
                onSuccess: function(t) {
                        error_msg = validateForm(step_num);
                        var validate = t.responseText;

                        if(validate.indexOf(' ') != -1){
                                var error_msg = validate;
                        }
                        //alert(validate);
                        if(error_msg == ""){
                                new Ajax.Request('crossjax.php?'+step_num, 
{parameters: $
(step_num).serialize(), onSuccess: function(){ goTo(goto_step); },
asynchronous: true});
                        } else {
                                errorStuff(button_msg,error_msg);
                        }
                },
                // Handle other errors
                onFailure: function(t) {
                        alert('Error: ' + t.status + ' -- ' + t.statusText);
                }
        }

        if(error_msg == ""){
                prepareStuff('Validating your information...');
                //var poststr = saveString('step1');
                new Ajax.Request('crossjax.php?' + step_num + '&validate', opt);

        } else {
                errorStuff(button_msg,error_msg);
        }

        return false;
}

On Mar 16, 10:42 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Currently I have 2 functions for saving data:
>
> function confirmStep2(){
>         var error_msg = validateForm('step2');
>
>         if(error_msg == ""){
>                 prepareStuff('Validating your information...');
>                 var poststr = saveString('step2');
>                 new Ajax.Request('crossjax.php?step2&validate', {parameters :
> poststr, onSuccess : saveStep2, asynchronous : true});
>         } else {
>                 errorStuff(error_msg);
>         }
>
>         return false;
>
> }
>
> function saveStep2(t){
>         var error_msg = validateForm('step2');
>
>         var validate = t.responseText;
>         if(validate.indexOf(' ') != -1){
>                 var error_msg = validate;
>         }
>
>         if(error_msg == ""){
>                 prepareStuff('Saving your information...');
>                 var poststr = saveString('step2');
>                 new Ajax.Request('crossjax.php?step2', {parameters : poststr,
> onSuccess : function(){ goTo('step3'); }, asynchronous : true});
>         } else {
>                 errorStuff(error_msg);
>         }
>         return false;
>
> }
>
> The problem is I can't pass any information onto the next function due
> to the fact that the onSuccess call of the first function won't allow
> me to enter any variables.
>
> How can I setup 1 function that will allow me to get a response back
> and make sure it's blank and then process the information again
> without a URL parameter, maybe something like this:
>
> function confirmStep2(var_i_need_for_second_step){
>         var error_msg = validateForm('step2');
>
>         if(error_msg == ""){
>                 prepareStuff('Validating your information...');
>                 var poststr = saveString('step2');
>                 new Ajax.Request('crossjax.php?step2&validate', {parameters :
> poststr, onSuccess : handleResponse, asynchronous : true});
>
>                 handleResponse = function(t) {
>                         var validate = t.responseText;
>                         if(validate.indexOf(' ') != -1){
>                                 var error_msg = validate;
>                         }
>
>                         if(error_msg == ""){
>                                 prepareStuff('Saving your information...');
>                                 new Ajax.Request('crossjax.php?step2', 
> {parameters : poststr,
> onSuccess : function(){ goTo(var_i_need_for_second_step); },
> asynchronous : true});
>                         }
>                 }
>         } else {
>                 errorStuff(error_msg);
>         }
>
>         return false;
>
> }
>
> This would be really helpful because I could then setup 1 function for
> all my steps, rather than having 1 for each step.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to