Jseb
Jseb

Reputation: 1934

Ruby on Rails with jquery load and sending data

I am wondering how I can send data. I have the following code

$( "#dialog" ).load('/events/relates ' + '#eventconfirm', { data: 'Hello World' }).dialog('open');

But it doesn't work. What I want is to load event/relates and only get the selection #eventconfirm, which works, but I would like to add data so the controller can read the params[:data] and act upon it.

Upvotes: 3

Views: 679

Answers (2)

Balaji Palani
Balaji Palani

Reputation: 1

Please try this:

$('.div').load("/test/okay?test=1");

where test=1 is params

Upvotes: 0

Dakait
Dakait

Reputation: 2620

no need to append the url and try calling the plugin in the .load callback like

$("#dialog").dialog();//first initailize the plugin
//then load the content 
$( "#dialog" ).load('/events/relates#eventconfirm', { data: 'Hello World' },function(data){
 $(this).dialog('open');
});

DEMO

Upvotes: 1

Related Questions