Getting empty string on tweeter button

Getting empty string on tweeter button
0.0 0



I’m having a bit of trouble because the string used to generate the tweeter address are returning empty so nothing gets passed to the dialog box to re tweet. Does anybody have a clue how to debug this?

$(’#text-quote’).text = " "

$(’#text-quote’).val = null


Any pointers are much appreciated.




Hi, @sebtn. Maybe you meant .text() (note the parentheses)?

I added a line in your code


// this line modifies the tweet link's `href` attribute.
$('#tweet').attr('href', '' + $('#text-quote').text() + $('#autor').text());

I also removed the line with the at the end of your code, since all it does is opens a new window at page load.



Thanks for the reply.

Sorry but still doesn’t work, the twitter page comes back empty which means,
$(’#text-quote’).text() + $(’#autor’).text()) is still returning an empty string, which is wierd


The line

$('#tweet').attr('href', '' + $('#text-quote').text() + $('#autor').text());

has to after the line $('#autor').html(post.title);.

You may have misread the code I posted. They all go together.


ahh ok, now it works. Thanks

Why doesn’t it work if it is outside the ajax request? What are the rules of thumb on the scope?


That line executes right at page load, during which both $('#text-quote') and $('#autor') still has empty strings as text.

In your case you want to change the href every time the quote is changed (i.e., every ajax request).