how to post the clicked element attribute with ajax
Hello,
I'm trying to post variables dynamically with ajax.
The code I have come up to until now is:
-
- $("#formid input").click(function() {
- var btnclick = $(this).attr("name");
- $.ajax({
- url: "mydomain.com",
- type: "POST",
- data: {id: "1", btnclick: "1"},
- success: function(data) {
- $(".comres").html(data);
- }
- });
-
- return false;
- });
The problem is that it is not posting the name of the clicked button but it must be posting btnclick=1 no matter what button was clicked.
Any tips?
Thanks in advance.
Spyros