Reputation: 13558
I have this JQuery code:
$("div.notification").live("click", function(){
window.location=$(this).find("a").attr("href");
var myId = $(this).attr("id");
$.post("/videos/selected_notification.js", myId);
return false;
});
I want to be able to access myId
from inside my controller that the post request hits. How do I do this?
Upvotes: 1
Views: 1089
Reputation: 434935
Give your myId
value a name and you can pull it out of params
just like any other POST parameter:
$.post("/videos/selected_notification.js", { id: myId });
And then, in the controller:
id = params['id'] # Or params[:id] since params is a HashWithIndifferentAccess
Upvotes: 2