From af20af8524b4a8a57b8c1f1ebe665c45a6f3d17a Mon Sep 17 00:00:00 2001 From: Patrick McElhaney Date: Mon, 19 Mar 2012 15:28:41 -0300 Subject: [PATCH] Fixed getLastModified callback firing three times (once for every readyState change). --- skel/template.html.erb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/skel/template.html.erb b/skel/template.html.erb index 930fc10..f98b656 100644 --- a/skel/template.html.erb +++ b/skel/template.html.erb @@ -44,9 +44,11 @@ http.open('HEAD', location, true); http.onreadystatechange = function() { - console.log(http); - console.log(http.getResponseHeader('Last-Modified')); - callback(http.getResponseHeader('Last-Modified')); + if(http.readyState === http.DONE) { + console.log(http); + console.log(http.getResponseHeader('Last-Modified')); + callback(http.getResponseHeader('Last-Modified')); + } }; http.send(); }