How to run jQuery onClick? Need to pass a variable to run .ajax
Posted
by user205307
on Stack Overflow
See other posts from Stack Overflow
or by user205307
Published on 2010-03-22T20:58:20Z
Indexed on
2010/03/22
21:01 UTC
Read the original article
Hit count: 163
I'm trying to run .ajax and insert a data element from the onClick of an item from the page. Whats the best way to do this?
Something like this:
function grabinfo(foo){
$.ajax({
url: "infospitter",
method: "GET",
data: "id="+foo,
success: function(html){
$(#showstuff).html(html);
}
});
}
<input onClick="javascript:grabinfo(18343)" />
// and on page each item will have this button input
© Stack Overflow or respective owner