Understanding promise.race() usage

As you see, the race() will return the promise instance which is firstly resolved or rejected: var p1 = new Promise(function(resolve, reject) { setTimeout(resolve, 500, ‘one’); }); var p2 = new Promise(function(resolve, reject) { setTimeout(resolve, 100, ‘two’); }); Promise.race([p1, p2]).then(function(value) { console.log(value); // “two” // Both resolve, but p2 is faster }); For a scenes … Read more

Load ajax when scroll reaches 80%

Provided your current check is firing when scrolled to the page’s bottom, you can try some basic arithmetics: if ($(window).scrollTop() >= ($(document).height() – $(window).height())*0.7){ //where 0.7 corresponds to 70% –^ Make sure to add a check to don’t fire multiple simultaneous Ajax requests, if you didn’t already. This is rather out of the scope of … Read more

Jquery datatables destroy/re-create

CAUSE When DataTables destroys the table because of the option destroy:true it restores original content and discards the content that you’ve generated. SOLUTION #1 Remove destroy:true option and destroy the table before you manipulate the table with destroy() API method. if ( $.fn.DataTable.isDataTable(‘#tblRemittanceList’) ) { $(‘#tblRemittanceList’).DataTable().destroy(); } $(‘#tblRemittanceList tbody’).empty(); // … skipped … $(‘#tblRemittanceList’).dataTable({ “autoWidth”:false, … Read more

CORS cookie credentials from mobile WebView loaded locally with file://

I realize this question is old, but I figured I’d throw in on it anyhow. In the case of CORS requests, the browser preflights them. What this means is – in spite of whatever $.ajax() method you are using, an OPTIONS request is sent to the server. What this preflighted OPTIONS request is actually doing … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)