<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>buntin.org &#187; Javascript</title>
	<atom:link href="http://buntin.org/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://buntin.org</link>
	<description></description>
	<lastBuildDate>Fri, 27 Aug 2010 16:28:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>jQuery Polling plugin</title>
		<link>http://buntin.org/2008/09/23/jquery-polling-plugin/</link>
		<comments>http://buntin.org/2008/09/23/jquery-polling-plugin/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 13:27:54 +0000</pubDate>
		<dc:creator>sethtrain</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://buntin.org/?p=8</guid>
		<description><![CDATA[I wanted to create a chatting application and decided to create a jQuery polling plugin specifically for that purpose.  I don&#8217;t know for sure if this is useful to anyone else but it works for me.

(function($) {
    $.fn.poll = function(options){
       var $this = $(this);
  [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to create a chatting application and decided to create a jQuery polling plugin specifically for that purpose.  I don&#8217;t know for sure if this is useful to anyone else but it works for me.</p>
<pre class="brush: jscript;">
(function($) {
    $.fn.poll = function(options){
       var $this = $(this);
       // extend our default options with those provided
       var opts = $.extend({}, $.fn.poll.defaults, options);
       setInterval(update, opts.interval);

       // method used to update element html
       function update(){
           $.ajax({
               type: opts.type,
               url: opts.url,
               success: opts.success
           });
       };
    };

    // default options
    $.fn.poll.defaults = {
       type: &quot;POST&quot;,
       url: &quot;.&quot;,
       success: '',
       interval: 2000
    };
})(jQuery);
</pre>
<p>*Usage*</p>
<pre class="brush: jscript;">
$(&quot;#chat&quot;).poll({
    url: &quot;/chat/ajax/1/messages/&quot;,
    interval: 3000,
    type: &quot;GET&quot;,
    success: function(data){
        $(&quot;#chat&quot;).append(data);
    }
});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://buntin.org/2008/09/23/jquery-polling-plugin/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
