Im making an Ajax get request in my Rails application.

This is the JS code.
function taxes() {
        var id_1 = $('tax_1').value;
        var url = '/taxes/tax_name/'+encodeURIComponent(id_1);
        var tax_1 = new Ajax.Request(url, {
            asynchronous: true, evalScripts: true,
            method: 'get'
        name_1 = tax_1;

And this is the controller code for the requested action.
def tax_name
    tax = Tax.find(params[:id])
    return tax.name

Fairly simple. But the output in the 'tax_1_name' div says "[object
Object]". Thats all. I guess that means the request is returning an
object. But how do i display the value correctly?
And ideally, I would like the request to return the tax (and not the
tax.name), and then use the returned ActiveRecord object in updating
various divs with various attributes of this returned object. How can
i do that?
Im new to prototype and hoping to play with all its goodies over the
next few weeks :D. Hope to find guidance here. Thanks!

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to