javascript - Rails jquery ajax request not firing -
in view:
<div> <%= radio_button_tag :profile_set, "profile picture", true, onclick: "set_profile(#{picturething.id});" %> </div> <script type="text/javascript"> function set_profile(picid) { alert("hello."); $.ajax({ type : 'post', url : '/update_profile_picture', datatype : 'script', data : { picid:picid, callsign:callsign, page_name:page_name } }); alert("goodbye."); }; </script> routes.rb:
post 'update_profile_picture', to: 'picturethings#update_profile', as: :update_profile_picture i can see browser console ajax request not firing, nothing happens. "hello" alert appears, code executing @ least far, falls on during ajax bit. "goodbye" alert never appears.
as per comment in question, ajax looks fine... make sure have defined page_name , callsign:
function set_profile(picid) { alert("hello."); $.ajax({ type : 'post', url : '/update_profile_picture', datatype : 'script', data : { picid:picid, callsign:callsign, page_name:page_name } }); alert("goodbye."); };
Comments
Post a Comment