I am showing a few dynamic links that use the same thing, ajax loads the content in the first link, but does not work for the rest. How can I load it to load the contents of other links into the same div?
Html:
$string .= '<a id="hrefid" data-id="'.$name["id"].'" href="link" >'.$name["name"].'</a>'.
<div id="content"> </div>
Jquery:
$('#hrefid').on('click', function (e) {
var load = $(e.target).attr("href");
if(load == "#link") {
$.ajax({
type: 'post',
url: "/page/test/"+id,
complete: function (event) {
$("#content").contents().remove();
$("#content").append(event.responseText);
}
});
}
});
source
share