Ajax call on button

How do i use a button to perform an ajax call. Im not updating/creating
a form so submit_to_remote wont work as it is expecting form options.

button_to_function is just for javascript from what ive read.

I could use css to maybe appear that it is a button but this is not the
route i want to take.

<%= submit_to_remote 'next_lever_btn', "Go to next" ,
    :url => { :action => "load_questions", :id => @next_cat},
    :before => "Element.show('main_spinner')",
    :success => "Element.hide('main_spinner')" %>

Anyone got a solution?

JB

You could use a link_to_remote and style it the way you want it.

You could use a link_to_remote and style it the way you want it.

How do i use a button to perform an ajax call. Im not updating/
creating
a form so submit_to_remote wont work as it is expecting form options.

button_to_function is just for javascript from what ive read.

So just use the right javascript!
button_to_function 'Click me', remote_function(:url => {...}, ...)

Fred

Frederick Cheung wrote: