When dealing with OAuth from the server, such as Twitter and Facebook, you most likely will redirect the user to an URL asking for app permission. Usually, after clicking a link
Try adding async: false. It should be working
$('#myButton').click(function() { $.ajax({ type: 'POST', async: false, url: '/echo/json/', data: {'json': JSON.stringify({ url:'http://google.com'})}, success: function(data) { window.open(data.url,'_blank'); } }); });