Skip to content

Commit

Permalink
Fix for outdated requests being processed
Browse files Browse the repository at this point in the history
  • Loading branch information
trishume committed Apr 13, 2016
1 parent d3887ae commit 4d0666f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion public/script/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var reqCorrelationQuery = null;
var curRecords = null;
var curOverlay = null;


var inFlightRequest = null;

// http://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript
function numberWithCommas(x) {
Expand Down Expand Up @@ -286,22 +286,27 @@ function handleNewData(oEvent) {
} else {
console.log("Couldn't fetch file " + url);
}
inFlightRequest = null;
}

function fetchCorrelationData(corrBuffer, filter) {
if(inFlightRequest !== null) inFlightRequest.abort();
var xhr = new XMLHttpRequest();
xhr.open("POST", "/find?"+encodeURIComponent(filter), true);
xhr.responseType = "arraybuffer";
xhr.onload = handleNewData;
xhr.send(new DataView(corrBuffer));
inFlightRequest = xhr;
}

function fetchRawData(filter) {
if(inFlightRequest !== null) inFlightRequest.abort();
var xhr = new XMLHttpRequest();
xhr.open("GET", "/raw?"+encodeURIComponent(filter), true);
xhr.responseType = "arraybuffer";
xhr.onload = handleNewData;
xhr.send(null);
inFlightRequest = xhr;
}

function updateFromServer() {
Expand Down

0 comments on commit 4d0666f

Please sign in to comment.