Ruby Rails - structuring data for AJAX call to controller action

后端 未结 2 574
野的像风
野的像风 2021-01-14 19:54

I have need for a button on my site which can send information to the create action of a controller (\"pagetimes\"). It seems to be working, although it is not sending all t

2条回答
  •  灰色年华
    2021-01-14 20:02

     function submitForm() {
          alert("checked the button - worked");
          $.ajax({
               type:'POST', 
               url: '/pagetimes/create', 
               data: $.param({ pagetime: {pagename: "whatever", start: 7, end: 21 }})
          });
     }
    

提交回复
热议问题