Running ajax request with cell link not working.
Running ajax request with cell link not working.
jigar311982
Posts: 70Questions: 31Answers: 0
Hello,
I have created cell link with below code,
{
targets: 1,
render: function(data, type, full, meta) {
return '<a href="#" class="viewVendorButton">'+ data +'</a>';
},
},
and then i am using below code on click button to pull html from server,
$(".viewVendorButton").on('click', function() {
jQuery.ajax({
url: "/purchases/renderviewvendor",
type: "POST",
success:function(data){
$data = $(data); // the HTML content that controller has produced
$('#vendorformcontainer').hide().html($data).fadeIn();
$('.selectpicker').selectpicker();
_SaveVendor();
}
});
});
Problem is that it is not fetching my HTML, in short anything happens on clicking on target 1.
If i use normal button like below code, it easitly fetch HTML,
<a href="#" class="btn btn-danger font-weight-bolder viewVendorButton"></a>
Not sure why cell link for working for AJAX call, normal link to another page is working fine.
This discussion has been closed.
Answers
Start with this FAQ about using delegated events. If you still need help then please post a link to your page or create a test case replicating the issue so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin