Angular DataTables sending three request initially to server
I'm using Angular DataTables library. Every thing is working fine(properly loading data in datatables) but i don't know why initially it sending 3 http request to the server on given url . I have searched but didn't find any solution.
Versions
- npm version: 3.10.10
- angular version: v1.5.9
- jquery version: v1.12.4
- datatables version: 1.10.15
- angular-datatables version: v0.5.5
Below is the code which i'm using. I make sure that this function is called only once (Not three time).
getData() {
var authorization = this.$http.defaults.headers.common["Authorization"];
var self = this;
debugger;
this.dtOptions = this.dTOptionsBuilder.newOptions()
.withOption('ajax',
{
contentType: 'application/json',
url: self.url,//server url to get data
type: "POST",
headers: { 'Authorization': authorization },
data(data) {
data.dataTableModel = self.dataTableModel;
data.order[0].name = data.columns[data.order[0].column].data;
data.query = data.search.value;
return JSON.stringify(data);
},
error(errorResponse) {
console.log(errorResponse);
}
})
.withDataProp('data')
.withOption('processing', true)
.withOption('serverSide', true)
.withOption('createdRow', (row, data, dataIndex) => {//row recompile
this.$compile(angular.element(row).contents())(this.$scope);
})
.withOption('headerCallback', header => {//header recompile
this.dtOptions.headerCompiled = true;
this.$compile(angular.element(header).contents())(this.$scope);
})
.withPaginationType("simple_numbers")
// .withOption("scrollY", 150)
// .withOption("Paging",false)
.withOption("lengthMenu", [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]])
.withBootstrap();
}
On Image you can see the three consecutive requests
You're probably making that ajax call some where else. I had a similar issue before.
Using the headerCallback will trigger the second call (not sure why though...). I don't know about the third one. You will need to investigate further in your code.
@rnunez100 and @l-lin thanks for the response . Oky i'm investigating my code again (May be i'm sending request somewhere ) and then i will let you know .