On Mon, Feb 27, 2012 at 3:43 PM, Vell <[email protected]> wrote:

> Hello all,
>
> I'm trying to write a jquery function where I am posting some data from a
> form. I am wondering is there a way to select the particular param that I
> want to use when I submit the data to $.ajax(). I don't believe it makes
> sense to create a hidden field just to use with $.ajax() but I can't seem
> to figure out how to get to the params key/value using jquery.
>
> The code that I am attempting to use is:
> $.ajax({
> url: "/app/controller/action",
> type: "POST",
> data: {code : 'param[:value]' or ??}
> });
>
> Can this be done at all? if so, what would be a good approach?
>
> Thanks,
>
> -



Lets say you have a form with an ID new_form

var form = $('#new_form');
  $.ajax({
    url: form.attr("action"),
    type: "POST",
    data: form.serialize(),
    cache: false,
    beforeSend: function(){
       //something here
    },
    complete: function(){
       // something here
    },
    success: function (result) {

        //here comes whatever you want

    }

  });

so instead of form.serialize() you have to send the variable you want
I think in the success function, or before send you should do an alert of
what is sending, then you will choose what you want to show after the
success

That's all, hope it helps

Javier Q

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to