<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Perplexed Labs - Latest Comments in PHP jQuery AJAX Javascript Long Polling</title><link>http://plabs.disqus.com/</link><description>web development war stories from the frontlines to the backend</description><atom:link href="https://plabs.disqus.com/php_jquery_ajax_javascript_long_polling/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Sat, 23 Feb 2013 23:08:10 -0000</lastBuildDate><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-810326537</link><description>&lt;p&gt;great&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Cuongnv2008</dc:creator><pubDate>Sat, 23 Feb 2013 23:08:10 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-538322895</link><description>&lt;p&gt;Can you give a tutorial where PHP polls memcache to retrieve data?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">AttitudeMonger</dc:creator><pubDate>Fri, 25 May 2012 08:20:24 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-529566388</link><description>&lt;p&gt;+1&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matttieu</dc:creator><pubDate>Tue, 15 May 2012 15:51:03 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-459682706</link><description>&lt;p&gt;I am not sure if NginX and fastcgi help so much here. You have one running PHP process per connection, right? And that process actively polls backend resources like DB or memcache for new information. That limits your number of connections much more than apache would ever do. How about XMPP, CometD or STOMP with a queue server behind them? Then you dont have such a hard limit on concurrent connections.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Gaylord</dc:creator><pubDate>Thu, 08 Mar 2012 06:46:43 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-439936792</link><description>&lt;p&gt;2 years later and still a good article. Thanks!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">waterloomatt</dc:creator><pubDate>Wed, 15 Feb 2012 12:28:57 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-335864003</link><description>&lt;p&gt;Is possible to refactor this to use shorter code and pure JavaScript. Not sure which is best to accomplish &lt;a href="http://techoctave.com/c7/posts/60-advanced-polling-with-jquery" rel="nofollow noopener" target="_blank" title="http://techoctave.com/c7/posts/60-advanced-polling-with-jquery"&gt;simple long polling JavaScript&lt;/a&gt; example, but I think I found it on that blog. Thanks!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jason</dc:creator><pubDate>Sun, 16 Oct 2011 00:46:10 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-290783511</link><description>&lt;p&gt;Hi, I have successfully implemented the above solution however if i have multiple tabs open then each tab will have a polling process. Is there a way to get around this as really I only want to poll on one tab.&lt;/p&gt;&lt;p&gt;Thanks&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kal</dc:creator><pubDate>Fri, 19 Aug 2011 04:53:28 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-289940688</link><description>&lt;p&gt;Great stuff!&lt;/p&gt;&lt;p&gt;I have successfully implemented this solution. However if I have multiple tabs open the notifications to duplicated. Is there any way to prevent this?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kal</dc:creator><pubDate>Thu, 18 Aug 2011 05:38:01 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-227304782</link><description>&lt;p&gt;Great work. &lt;br&gt;also here you can find the demo and pool script here, &lt;a href="http://www.webfreescripts.com/?p=1380" rel="nofollow noopener" target="_blank" title="http://www.webfreescripts.com/?p=1380"&gt;http://www.webfreescripts.com/?p=1380&lt;/a&gt; &lt;br&gt;its easy and interesting.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Bbestkhalid</dc:creator><pubDate>Thu, 16 Jun 2011 09:56:35 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-178226912</link><description>&lt;p&gt;You need to add "async:true" to config options for the main ajax request&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">NoICE</dc:creator><pubDate>Mon, 04 Apr 2011 18:45:20 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-176170683</link><description>&lt;p&gt;Nice article, but can we make an other ajax-call ? While the ajax-long-polling is running ?&lt;/p&gt;&lt;p&gt;I don't think so, so we block any ajax actions ? Or I am wrong, I have just tried, and I've got this error.&lt;br&gt;Thanks !&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Vdecaux83</dc:creator><pubDate>Fri, 01 Apr 2011 10:12:24 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-50622526</link><description>&lt;p&gt;It is very nice. I'll try this tommorow. Thanks to author :)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mirgorod Vadym</dc:creator><pubDate>Sun, 16 May 2010 15:48:07 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-41967796</link><description>&lt;p&gt;Hello,&lt;/p&gt;&lt;p&gt;Awesome post on jQuery and PHP implementation!&lt;/p&gt;&lt;p&gt;I like the 30 second handler implementation...really simple and good idea to handle it there...&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matt M. Kaufman</dc:creator><pubDate>Sun, 28 Mar 2010 02:41:33 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-24467128</link><description>&lt;p&gt;Wow great post, does this FB Work?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">TJ Mapes</dc:creator><pubDate>Tue, 01 Dec 2009 16:37:28 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-16643392</link><description>&lt;p&gt;Thank you... Thank you...Hey did i say THANK YOU!&lt;br&gt;You probably saved 2 weeks of my life :)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Marko Jovanovic</dc:creator><pubDate>Tue, 15 Sep 2009 15:51:53 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-16522507</link><description>&lt;p&gt;thanks for correction in memcache matt, great..&lt;/p&gt;&lt;p&gt;sorry, the code above was alert(bidid) not alert('bidid');&lt;br&gt;the alert box is displayed well with returned data from xml&lt;br&gt;it works in all browser except in I.E all version&lt;br&gt;in I.E the alert box is not displayed.. that's the problem&lt;/p&gt;&lt;p&gt;Well anyway I just have find the way to make it works in IE&lt;br&gt;I changes the lpStart function as follow:&lt;/p&gt;&lt;p&gt;&lt;code&gt;&lt;br&gt;	var lpStart = function() {&lt;br&gt;		$.ajax({&lt;br&gt;			type: "POST",&lt;br&gt;			cache: false,&lt;br&gt;			url: "proc.php",&lt;br&gt;			success: lpOnComplete&lt;br&gt;		});&lt;br&gt;	};&lt;br&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;as u suggest for the memcache in proc.php i put this following code.. &lt;br&gt;&lt;code&gt;&lt;br&gt;&lt;br&gt;		  &amp;lt;data&amp;gt;" . memcache_get($memcache_obj, 'bid') . "&amp;lt;/data&amp;gt;";  &lt;br&gt;&lt;br&gt;	// data is always new&lt;br&gt;	if(!empty($data)){&lt;br&gt;		Header("Content-Type: text/xml");&lt;br&gt;		flush();&lt;br&gt;		usleep(1000000);&lt;br&gt;		echo $data;&lt;br&gt;		break;&lt;br&gt;	}&lt;br&gt;}&lt;br&gt;?&amp;gt;&lt;br&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;it's using 2 thread on apache with keep alive connection, better than using setTimeout or setInterval, which use 60 thread for every second retrieving new data.&lt;/p&gt;&lt;p&gt;I hope it help the other who get the problem in IE.. this browser always make me work twice.. &lt;br&gt;Thank you matt.. much appreciated.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">imwoodie</dc:creator><pubDate>Sat, 12 Sep 2009 21:23:08 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-16506310</link><description>&lt;p&gt;A couple things.&lt;/p&gt;&lt;p&gt;You should move your memcache connection line outside the while loop - you don't want to reconnect every iteration.&lt;/p&gt;&lt;p&gt;$data, the way you have it written, can never be empty so the loop will always only run one iteration.&lt;/p&gt;&lt;p&gt;If there are no script errors being reported, is an empty alert box being displayed?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matt Reiferson</dc:creator><pubDate>Sat, 12 Sep 2009 14:26:01 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-16502160</link><description>&lt;p&gt;thanks for reply matt.. appreciate.&lt;/p&gt;&lt;p&gt;well there's no error code in I.E, I'm not using jason but xml as a data..&lt;br&gt;here are code that I try to implement :&lt;/p&gt;&lt;p&gt;&lt;code&gt;&lt;br&gt;&amp;lt;script src="jquery-1.3.2.min.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;&lt;br&gt;&amp;lt;script type="text/javascript"&amp;gt;&lt;br&gt;	var lpOnComplete = function(response) {&lt;br&gt;		$(response).find('id').each(function(){&lt;br&gt;			var id = $(this); &lt;br&gt;			bidid = id.attr("id");&lt;br&gt;			alert('bidid');&lt;br&gt;		// do more processing&lt;br&gt;		});&lt;br&gt;		&lt;br&gt;		lpStart();&lt;br&gt;	};&lt;br&gt;	&lt;br&gt;	var lpStart = function() {&lt;br&gt;		//$.ajaxSetup({ cache: false });&lt;br&gt;		$.get('proc.php',  { }, lpOnComplete, 'XML');&lt;br&gt;	};&lt;br&gt;	&lt;br&gt;	$(document).ready(lpStart);&lt;br&gt;&amp;lt;/script&amp;gt;&lt;br&gt;&lt;code&gt;&lt;br&gt;&lt;br&gt;This is &lt;em&gt;proc.php&lt;/em&gt;, I'm using memcache&lt;br&gt;&lt;br&gt;&lt;code&gt;&lt;br&gt;&lt;br&gt;		  &amp;lt;data&amp;gt;" . memcache_get($memcache_obj, 'bid') . "&amp;lt;/data&amp;gt;"; &lt;br&gt;&lt;br&gt;	// data is always new&lt;br&gt;	if(!empty($data)) {&lt;br&gt;		Header("Content-Type: text/xml");&lt;br&gt;		echo $data;&lt;br&gt;		break;&lt;br&gt;	}&lt;br&gt;	usleep(2500);&lt;br&gt;	flush();&lt;br&gt;}&lt;br&gt;?&amp;gt;&lt;br&gt;&lt;/code&gt;&lt;br&gt;&lt;br&gt;It doesn't work in I.E&lt;br&gt;&lt;br&gt;Thanks again matt&lt;br&gt;&lt;/code&gt;&lt;/code&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">imwoodie</dc:creator><pubDate>Sat, 12 Sep 2009 13:02:26 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-16429926</link><description>&lt;p&gt;have you tried enabling script debugging to see what line of code is causing the problem?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matt Reiferson</dc:creator><pubDate>Fri, 11 Sep 2009 13:11:55 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-16294037</link><description>&lt;p&gt;Hi, I'm using jquery-1.3.2.. I try to implement your code and is running well in FF, safari, and opera. but it doesn't work in IE.. would you like to give me a clue.. thank you&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">imwoodie</dc:creator><pubDate>Thu, 10 Sep 2009 03:37:59 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-15882758</link><description>&lt;p&gt;&amp;gt; sleep(25000);&lt;br&gt;it's about 7 hours ;)&lt;br&gt;may be usleep(25000) ?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">d1Mm</dc:creator><pubDate>Thu, 03 Sep 2009 10:39:36 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-11728271</link><description>&lt;p&gt;Try session_write_close(); I wasted 2 weeks of my life to get rid of it, But session_write_close() helped me. Problem was exactly the same.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Az</dc:creator><pubDate>Thu, 25 Jun 2009 12:02:13 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-10690982</link><description>&lt;p&gt;OK, thanks Matt, much appreciated.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dave</dc:creator><pubDate>Wed, 10 Jun 2009 04:32:11 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-10673411</link><description>&lt;p&gt;Dave,&lt;/p&gt;&lt;p&gt;I think you're thinking about this wrong.  You don't need FastCGI in order to scale an app that uses this technique.  FastCGI just happens to be a common interface of servers that are able to scale with an app using this technique.&lt;/p&gt;&lt;p&gt;Lighttpd would be my suggested choice given that it's easy to get PHP up and running on it and is fairly easy to install.&lt;/p&gt;&lt;p&gt;-Matt&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Matt Reiferson</dc:creator><pubDate>Tue, 09 Jun 2009 19:16:40 -0000</pubDate></item><item><title>Re: PHP jQuery AJAX Javascript Long Polling</title><link>http://www.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/#comment-10671844</link><description>&lt;p&gt;What about LiteSpeed with FastCGI support? Any known issues with that or does it fall under the same category as Lighttpd and nginx?&lt;/p&gt;&lt;p&gt;Thanks,&lt;/p&gt;&lt;p&gt;Dave&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dave</dc:creator><pubDate>Tue, 09 Jun 2009 18:19:35 -0000</pubDate></item></channel></rss>