We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50539
    • 1 Posts
    Hi,

    Currently working on a project with some extended forms. I got almost everything working now. The form works fine, all the fields got processed and emailed to me. Only I'm running into a small problem; I'm using a jQuery validation on the forms, got the formIt validation also build in as a secondery validation. Only i'm getting the following problem:

    - After submitting, the form is validated by jQuery before formit is processing the form. This go's just fine and everything got proccessed and emailed. Only the redirect hook isn't working/triggered. Below are some details on my form:

    MODX version: 2.3.3
    Formit version: 2.2.6

    Formit call(only the redirect):

    &hooks=`spam,email,redirect`
    &redirectTo=`2`


    After submitting the form, i'm using the following code;

    onSubmit: function(invalid, e) {
    e.preventDefault();
    
         if (invalid) {
            alert(invalid +' fields!');
         } 
         else {
            $.post( "[[~[[*id]]]]", this.$form.serialize() );
         }
    }


    As I said, everything works fine, only the redirect isn't triggered/working. I tried it without the jQuery validation and the redirect is working fine then, so it's no error on the formIt side. I'm not realy a JS expert, so hoping someone here can put me in the right direction.
      • 4172
      • 5,888 Posts
      redirecting at the ajax-controller doesn't work, of course.
      you would need to redirect by javascript with:

      location.href = "[[~2]]";


      after successfull ajax-response.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!