Simple Ajax Request on button in a row

Simple Ajax Request on button in a row

zdweebzdweeb Posts: 3Questions: 0Answers: 0
edited May 2011 in General
I all, I have searched the forum for an answer to my question. I am not a well versed or any verse in javascript. What I am trying to do is very simple.

I want to have a hidden column with an id. Then I want a column with a button for each row that when clicked will make a ajax request to start a background process, the loding img should appear and when finished it will return some text.

So here is my js code;
[code] $.ajaxSetup ({
cache: false
});
var ajax_load = "";
var loadUrl = 'hadoop/train';

$("#train").click(function(){
$("#result")
.html(ajax_load)
.load(loadUrl, null;
});
[/code]

and here is my button code, which I have no clue how to fire the #train event, tried an onclick but no go.;

[code]



[/code]

Thanks in advance, your help is greatly appreciated.

Replies

  • zdweebzdweeb Posts: 3Questions: 0Answers: 0
    Bump

    Sorry for the bump, could someone please help me with this. I know it is simple but I just can't seem to figure it out.

    Thanks
  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    I'd suggest using a live event ( $().live() ) rather than $().click, since it should make things a little easier. Something like $('#whatever_the_table_id_is input[type=submit]').live('click', function () {...} ); Then you can use fnGetData ( http://datatables.net/api#fnGetData ) to get the row ID and fire off the Ajax request.

    Allan
This discussion has been closed.