With Rails UJS, how to submit a remote form from a function

前端 未结 3 1121
执笔经年
执笔经年 2021-02-05 10:44

I\'m using Rails UJS. I have a form setup to do a remote submit like so:

3条回答
  •  盖世英雄少女心
    2021-02-05 11:11

    Try doing an Ajax request by yourself:

    $('#new_suscription').submit(function(){
      /*do whatever you want here*/
      $.post('/subscriptions',$(this).serialize(),function(){},'script');
    }
    

    That way, you do a POST request with the form data and execute the response as a script.

提交回复
热议问题