Home>
$ ('Document'). Ready (Function ()
{
    $ ('# Auth'). AjaxForm ({
        Target: '#PreView',
        SUCCESS: FUNCTION () {
            $ ('# Auth'). Resetform ();
        }
    });
});

I use jQuery.form To send form. Next I get the answer, but if the answer for example 'Noaccess' , I will restart the page, and if there is no such answer, it does not reboot anything. How to implement in this case?

  • Answer # 1

    Use the function parameter Callback

    jQuery (Function ($)
      {
        $ ('# Auth'). AjaxForm ({
        Target: '#PreView',
        SUCCESS: FUNCTION (DATA) {
                if (data== 'noauth') $ ('# auth'). resetform ();
            }
        });
     });
    
  • Answer # 2

    Use the function parameter Callback

    jQuery (Function ($)
      {
        $ ('# Auth'). AjaxForm ({
        Target: '#PreView',
        SUCCESS: FUNCTION (DATA) {
                if (data== 'noauth') $ ('# auth'). resetform ();
            }
        });
     });