From cc6aa9a2e4d036c24895bbf7a8dfb92bb400df90 Mon Sep 17 00:00:00 2001 From: Ed Barwani Date: Wed, 7 Aug 2013 11:08:35 +1000 Subject: When polling check if data is defined Prevent a javascript error that could stop polling. This happens when a request returns a 204 No Content. jQuery success callback has no data in this case causing an error. --- priv/bullet.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/priv/bullet.js b/priv/bullet.js index 7cc9fb5..26a1fc5 100644 --- a/priv/bullet.js +++ b/priv/bullet.js @@ -59,7 +59,7 @@ contentType: 'application/x-www-form-urlencoded; charset=utf-8', headers: {'X-Socket-Transport': 'xhrPolling'}, success: function(data){ - if (data.length !== 0){ + if (data && data.length !== 0){ self.onmessage({'data': data}); } } @@ -181,7 +181,7 @@ fake.onopen(fake); } // Connection might have closed without a response body - if (data.length !== 0){ + if (data && data.length !== 0){ fake.onmessage({'data': data}); } if (fake.readyState == OPEN){ -- cgit v1.2.3