From 1131422007f15be6b73c125c8b144d8029bd0459 Mon Sep 17 00:00:00 2001 From: Sissi Date: Sat, 14 Feb 2015 00:14:41 +0100 Subject: [PATCH] bugfix: script threw javascript error when response was null --- twitter/jquery.tweet.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/twitter/jquery.tweet.js b/twitter/jquery.tweet.js index e2c3611..6aa3b92 100644 --- a/twitter/jquery.tweet.js +++ b/twitter/jquery.tweet.js @@ -30,6 +30,7 @@ auto_join_text_reply: "i replied to", // [string] auto tense for replies: "i replied to" @someone "with" auto_join_text_url: "i was looking at", // [string] auto tense for urls: "i was looking at" http:... loading_text: null, // [string] optional loading text, displayed while tweets load + loading_text_error: 'Sorry, Tweets did not load.', // [string] optional text in case Tweets could not get loaded refresh_interval: null , // [integer] optional number of seconds after which to reload tweets twitter_url: "twitter.com", // [string] custom twitter url, if any (apigee, etc.) twitter_api_url: "api.twitter.com", // [string] custom twitter api url, if any (apigee, etc.) @@ -273,16 +274,16 @@ data: { request: build_api_request() }, success: function(data, status) { - if(data.message) { - console.log(data.message); - } - var response = data.response; + $(widget).empty().append(list); if (s.intro_text) list.before(intro); list.empty(); - if(response.statuses !== undefined) { + if (!response) { + $(widget).html(s.loading_text_error); + return false; + } else if (response.statuses !== undefined) { resp = response.statuses; } else if(response.results !== undefined) { resp = response.results; @@ -308,4 +309,4 @@ }).trigger("tweet:load"); }); }; -})); \ No newline at end of file +}));