question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Server side start with twice request

See original GitHub issue

I’m using with server side processing and when it initializes, the request to server is duplicated.

<table datatable dt-options="dtOptions" dt-columns="dtColumns"></table>
$scope.dtOptions = DTOptionsBuilder.newOptions()
  .withOption('ajax', { url: String.format('{0}api/System/Message/Get', BASEURL) })
  .withDataProp('data')
  .withOption('serverSide', true)
  .withOption('processing', true)
  .withOption('order', [[0, 'asc'], [1, 'asc']])
  .withBootstrap();

$scope.dtColumns = [
  DTColumnBuilder.newColumn('cdMessage').withTitle('Id').withOption('width', 110),
  DTColumnBuilder.newColumn('cdCulture').withTitle('Culture').withOption('width', 100),
  DTColumnBuilder.newColumn('tpMessage').withTitle('MessageType').withOption('width', 160),
  DTColumnBuilder.newColumn('dsMessage').withTitle('MessageDescription'),
  DTColumnBuilder.newColumn('dsDetails').withTitle('MessageDetails')
];

Firebug request

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:23 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ralphitecommented, Aug 25, 2015

Hi, I’m seeing the same issue in v0.4.3.

0reactions
dashawkcommented, Aug 17, 2017

It is because of the promises.

In the first load of your page, you must set the tableOptions and tableColumns with an empty promise.

// I personally don't like this approach. It should have been handled by the directive already
vm.tableOptions = $q.defer().promise;
vm.tableColumns = $q.defer().promise;

// After Loading the DOM, add your options
vm.tableOptions = DTOptionsBuilder ... // or $resource().query().$promise;
vm.tableOptions = DTColumnsBuilder ... // or $resource().query().$promise;

This is what I noticed, if the DOM is not yet ready, the tableOptions will attempt to call for an ajax request, but since the <table datatable is not yet present, it will not do anything, you just be able to see the request first hand, then after the DOM is loaded, then the datatable directive will start the tableOptions to call for an ajax request, that is why there are two requests after the page load.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Server-side redirect without calling GET twice - Stack Overflow
1 Answer 1 · fetch makes a POST request to /page-1 · The server responds saying "You need to get page-2 instead" ·...
Read more >
Can an HTTPS request be sent twice?
Since a successfully replayed packet essentially means that an attacker was able to actively fiddle with the underlying reliable TCP connection, ...
Read more >
AXIOS sending Request Twice - Laracasts
I send a POST request to a API server and the request sent 2 times. The initial request succeed because the records are...
Read more >
load from +page.ts called twice - why? : r/sveltejs - Reddit
As the title says: I have a setup that has some code in a +page.ts , that fetches some data from an API....
Read more >
Server script runs twice with AngularJS directive - ServiceNow
... of the widget/button to depend on the result of a server-side call. ... the angular directive causes the server script to run...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found