Ruby Rails - structuring data for AJAX call to controller action

后端 未结 2 548
野的像风
野的像风 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 }})
          });
     }
    
    0 讨论(0)
  • 2021-01-14 20:25
    $.post( "/pagetimes/create", { pagename: "whatever", start: "7", end: "21"  })
    .done(function( data ) {
      alert( "Data Loaded: " + data );
    });
    
    0 讨论(0)
提交回复
热议问题