[jQuery] jQuery - Click function + Ajax
Hi there,
I have a hyperlink ( <a> ) after i click on that hyperlink, the script
sends some data to a .php page;
That works fine, but for just one hyperlink , i want to be able to
have 2 or more hyperlinks in the same page using the same script.
Here goes the script:
$("#button").click(function(){
var element = this;
var productId = $(element).attr('product');
//$(element).attr("href", "javascript: void(0);");
$.ajax({
type: "GET",
url: "index.php",
data: "product=" + productId
});
});
HTML:
<a id="button" rel="nofollow" product="10" href="#test">Product 10</a>
<a id="button" rel="nofollow" product="20" href="#test">Product 20</a>