Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery - growlUI Notification using screen scraped tweet
    text
    copied!<p>I am trying to pull my latest tweet into a variable in javascript, then use growlUI() to display this in a notification in jQuery.</p> <p>Currently, I have pulled my tweet using PHP into a variable in javascript called test. I need to adjust the following jQuery code to use "test" instead of "Hello".</p> <p>Current code works:</p> <pre><code>$.growlUI('Growl Notification','Hello'); </code></pre> <p>Attempted code does not work:</p> <pre><code>$.growlUI('Growl Notification', $(test)); </code></pre> <p><strong>My Question</strong></p> <p><strong>How do I use the variable test, which is a javascript variable, as a jQuery attribute?</strong></p> <p>Many thanks!</p> <p>My source code:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;!-- Styling for growlUI --&gt; &lt;style type="text/css"&gt; div.growlUI { background: url(check48.png) no-repeat 10px 10px } div.growlUI h1, div.growlUI h2 { color: white; padding: 5px 5px 5px 75px; text-align: left } &lt;/style&gt; &lt;!-- Import jquery from online --&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"&gt;&lt;/script&gt; &lt;!-- Import blockUI --&gt; &lt;script type="text/javascript" src="js/jquery.blockUI.js"&gt;&lt;/script&gt; &lt;script type = "text/javascript"&gt; &lt;!-- Screenscrape using PHP, put into javascript variable 'test' --&gt; &lt;?php $url = "http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=XXXXXXXXXX"; $raw = file_get_contents($url); $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B"); $content = str_replace($newlines, "", html_entity_decode($raw)); $start = strpos($content,'&lt;text&gt;'); $end = strpos($content,'&lt;/text&gt;',$start); $latesttweet = substr($content,$start,$end-$start); echo "var test = ".$latesttweet.";\n"; ?&gt; &lt;/script&gt; &lt;/head&gt; &lt;!-- Here I'm attempting to use test variable in second half of growlUI parameters --&gt; &lt;body onLoad="$.growlUI('Latest Update',test); "&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload