Web Intents: Javascript action AFTER user is actually followed instead of on Follow button click (using twttr.events.bind('follow'))


I want to reload my web page after the visitor follows a user. I’m using the following code to achieve that:

window.twttr = (function (d,s,id) { var t, js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js=d.createElement(s); js.id=id; js.src="https://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs); return window.twttr || (t = { _e: [], ready: function(f){ t._e.push(f) } }); }(document, "script", "twitter-wjs"));
  twttr.ready(function (twttr) {
	twttr.events.bind('follow',   function(e) {
What happens is after the follow button is clicked the page instantly refreshes, regardless of if the user has actually been Followed. I assume this is because Twitter's 'follow' event javascript is called WHILE the 'follow' action is still being called, instead of after. So when Twitter is slow or users have slow internet, the page will refresh after the Follow button is clicked, but the user isn't actually being followed. I can set a 1 second timeout on the location.reload, and the user follow will get followed about 4 out of 5 times depending on Twitter's speed.

Facebook has a similar javascript api, but their ‘Like’ event is called AFTER the page is liked, rather than during (or immediately on the Like button click). It returns something which tells the javascript widget that the Like actually went through before it continues to execute the code in the event bind.

Is there a way to do ‘location.reload’ when the user is actually followed, rather than calling it instantly after the button is clicked? If not, then this is a suggestion for a Twitter widget-js update :slight_smile:


Bumping for some extra info hopefully!


I am also having this problem.