<?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/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Anthology of Ideas &#187; AJAX</title>
	<atom:link href="http://anthologyoi.com/tag/ajax/feed" rel="self" type="application/rss+xml" />
	<link>http://anthologyoi.com</link>
	<description>Anthology of Ideas is an archive of thoughts and form.</description>
	<lastBuildDate>Sat, 03 Mar 2012 11:16:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Short Ajax Script</title>
		<link>http://anthologyoi.com/dev/short-ajax-script.html</link>
		<comments>http://anthologyoi.com/dev/short-ajax-script.html#comments</comments>
		<pubDate>Tue, 13 May 2008 15:40:50 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/blogish/asides/minimalist-ajax-script.html</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<div id="flickrImage_4" class="wp-caption alignleft" style="width: 250px"><a href="http://www.flickr.com/photos/jaywood/" rel="nofollow"  target="_blank"><img src="http://farm7.static.flickr.com/6065/6126357875_ca3058c8fd_m.jpg" width="240" height="160" /></a><p class="wp-caption-text">AJAX - it</p></div>
<p>I wanted to see how small you could make a fully functional AJAX script that worked cross-browser and degraded gracefully, so I went through an old custom AJAX script and made it as small as I possibly could. In the resulting AJAX scripts, the post version is 410 characters and the GET version is only 359 characters long. The scripts are fully functional and accept the following parameters: URL, DATA (in string form), and ELEMENT (to update).</p>
<p>The scripts could be a little smaller, but it would really kill readability. </p>
<h3>&#8220;Get&#8221; AJAX Script</h3>
<p><pre class="brush: php">function a(l,d,u){
try{r = new XMLHttpRequest();}catch(e){try {r = new ActiveXObject(&#039;Msxml2.XMLHTTP&#039;);}catch(e){r = new ActiveXObject(&#039;Microsoft.XMLHTTP&#039;);}}
if(r){
r.onreadystatechange = function() {if (r.readyState == 4 &amp;&amp; r.status == 200){document.getElementById(u).innerHTML = r.responseText;}}
r.open(&#039;GET&#039;, l+&#039;?&#039;+d, true);r.send(d);
}
}</pre></p>
<h3>&#8220;Post&#8221; AJAX Script</h3>
<p><pre class="brush: php">function b(l,d,u){
try{r = new XMLHttpRequest();} catch(e){try {r = new ActiveXObject(&#039;Msxml2.XMLHTTP&#039;);} catch(e){r = new ActiveXObject(&#039;Microsoft.XMLHTTP&#039;);}}
if(r){
r.onreadystatechange = function() {if (r.readyState == 4 &amp;&amp; r.status == 200){document.getElementById(u).innerHTML=r.responseText;}}
r.open(&#039;POST&#039;, l, true);r.setRequestHeader(&#039;Content-type&#039;, &#039;application/x-www-form-urlencoded&#039;);r.send(d);
}
}</pre></p>
<h3>Combined AJAX Script</h3>
<p>This combined script also accepts a fourth parameter &#8216;p&#8217; that should evaluate true if the data is to be sent by post.</p>
<p><pre class="brush: php">function a(l,d,u,p){
try{r = new XMLHttpRequest();}catch(e){try {r = new ActiveXObject(&#039;Msxml2.XMLHTTP&#039;);}catch(e){r = new ActiveXObject(&#039;Microsoft.XMLHTTP&#039;);}}
if(r){
r.onreadystatechange = function() {if (r.readyState == 4 &amp;&amp; r.status == 200){document.getElementById(u).innerHTML = r.responseText;}}
if(p){r.open(&#039;POST&#039;, l, true);r.setRequestHeader(&#039;Content-type&#039;, &#039;application/x-www-form-urlencoded&#039;);}else{r.open(&#039;GET&#039;, l+&#039;?&#039;+d, true);}
}
}</pre></p>
<p>Demo: (Sorry but you will have to go to the full page so the JavaScript is loaded.) <span id="more-220"></span><br />
<a href="?p=220" onclick="b('http://anthologyoi.com/index.php','p=220','hi'); return false;">Click here to see the POST HTML of the homepage</a><br />
<a href="?p=220" onclick="a('http://anthologyoi.com/index.php','p=220','hi'); return false;">Click here to see the GET HTML of the homepage</a><br />
 (they are the same)<br />
<textarea id="hi" rows="5" columns="5"></textarea></p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/dev/short-ajax-script.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Trapping WordPress errors with output buffering.</title>
		<link>http://anthologyoi.com/wordpress/trapping-wordpress-errors-with-output-buffering.html</link>
		<comments>http://anthologyoi.com/wordpress/trapping-wordpress-errors-with-output-buffering.html#comments</comments>
		<pubDate>Wed, 15 Aug 2007 17:05:21 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[die]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[output buffering]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/wordpress/trapping-wordpress-errors-with-output-buffering.html</guid>
		<description><![CDATA[If you have tried to use AJAX with WordPress, most likely you have stumbled upon the wp_die() function which completely kills the response you expect to get. However, we can trap the wp_die() by using PHP&#8217;s output buffering and the &#8230; <a href="http://anthologyoi.com/wordpress/trapping-wordpress-errors-with-output-buffering.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you have tried to use AJAX with WordPress, most likely you have stumbled upon the wp_die() function which completely kills the response you expect to get. However, we can trap the wp_die() by using PHP&#8217;s output buffering and the ob_start callback function to process the output of wp_die() even though a die() is called. This is a very special case, and will only work when you are able to ensure output buffering can be called before the die is called. </p>
<p>The easiest way to get a non-fatal wp_die() error (an error that shouldn&#8217;t cause the entire application to stop)  is when submitting comments: non-fatal errors occur whenever someone posts too quickly or submits a duplicate comment, so this can be a problem when creating an AJAX app to submit comments (I ran into this problem with <a href="http://anthologyoi.com/inap/">INAP</a>.) </p>
<p>Since AJAX makes the entire submit process very quick, so it is easy to trigger the &#8220;Posting too quickly&#8221; error if the user make short comments, and when this happens an entire page &#8211;complete with CSS and headers&#8211; is returned as the AJAX response. Originally, I detected this by updating the element and then doing doing a regex test on it. If it was an error, I would use another Regex to strip out the error message and update the element again, but because of the CSS, if the same user triggered an error multiple times (eg testing to see if they could submit the comment yet) there would be a momentary flash. I fixed this problem by updating a variable instead of going straight to the element, but it still required using client-side code to process it. </p>
<p>The Setup:<br />
 Some data is posted through AJAX to the server-side script. This script then calls a function (submit_data) which then passes on the data to WordPress. (There is of course PHP and JavaScript that isn&#8217;t shown here.)</p>
<p>The Original Function:<br />
<pre class="brush: php">function submit_form(){
global $wpdb, $post,$id;
	require_once(&#039;../../../../wp-comments-post.php&#039;);
	echo &#039;Comment submitted&#039;;
}</pre><br />
The original function just includes the WordPress file that processes the comments. If the Comment is a success WordPress doesn&#8217;t output any data and the &#8220;Comment submitted&#8221; message is echo&#8217;d. However if there is an error, the error message is outputted and the die() is called before the echo occurs. </p>
<p>The new function that traps the error:<br />
<code title="example code"><br />
function submit_form(){<br />
global $wpdb, $post,$id;<br />
	ob_start("nodie");<br />
		require_once('../../../../wp-comments-post.php');<br />
	ob_end_clean();<br />
	echo 'Comment submitted';<br />
}</p>
<p>function nodie($error){<br />
	return $error;<br />
}<br />
[/sourcecode]</p>
<p>Now we have added the lines line 3 and line 5, plus a new function nodie(). The ob_start callback function (the string we pass to it) is only called if that specific ob_start() is supposed to output text. This only happens two times:  when ob_end_flush() is called or if something inside the ob_start function outputs texts and then a die() is called. When the callback function is called the contents of the output buffer is passed as a string and a string should be returned. </p>
<p>In our function we use ob_end_clean() instead of ob_end_flush() which means the contents of the output buffer is destroyed, not echo'd, so the only time the call back function is called is when, you guessed it, we have an error and WordPress die()'s inside the ob_start().</p>
<p>Now the nodie() function doesn't do anything, but with a little RegEX magic it will return just the error string. Because submitting comments only returns a single error we can just look for the &lt;p&gt;, but if multiple errors may be returned you may want to look for a &lt;ul> also. </p>
<p><pre class="brush: php">function nodie($error){
	preg_match(&#039;@&lt;p&gt;(.*?)&lt;/p&gt;@&#039;, $error,$errs);
	return $errs[1];
}</pre></p>
<p>A couple final notes. Inside the nodie function anything that is outputted will not be returned (eg no echo's or print_r's), but you can call other functions and return their output as a string, so you can create an entire error handling application. Alao, WordPress adds a header to the wp_die() page of text/html if this is inappropriate for your application you can block this by adding the following lines to your function that could cause the error.</p>
<p><pre class="brush: php">Global  $wp_actions;
 $wp_actions[] = &#039;admin_head&#039;;</pre></p>
<p>It is rather hackish, but it works. You then can set the header you need in your callback function.</p>
<p>Of course this technique can be used on a larger scale to completely transform the wp_die page, but in the process, it will require that you trap all content in output buffering, and this method can be used with any other PHP program that you don't have direct control over.</p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/wordpress/trapping-wordpress-errors-with-output-buffering.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>INAP 3.0 Progress</title>
		<link>http://anthologyoi.com/wordpress/plugins/inap-30-progress.html</link>
		<comments>http://anthologyoi.com/wordpress/plugins/inap-30-progress.html#comments</comments>
		<pubDate>Tue, 14 Aug 2007 04:57:25 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[INAP]]></category>
		<category><![CDATA[private beta]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/blogish/asides/inap-30-progress.html</guid>
		<description><![CDATA[Aside from a brief flirtation with a couple payed projects, I&#8217;ve been heavily focusing on rewriting the code for INAP 3.0, and it has almost reached the point of a private beta (which means I start running it on this &#8230; <a href="http://anthologyoi.com/wordpress/plugins/inap-30-progress.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Aside from a brief flirtation with a couple payed projects, I&#8217;ve been heavily focusing on rewriting the code for INAP 3.0, and it has almost reached the point of a private beta (which means I start running it on this site.) I have selected the new name for INAP 3.0, but I&#8217;m not going to reveal it just yet. Here is a small preview of what you can expect from INAP 3.0:</p>
<p>INAP 3.0 is now truly modular with a main Javascript/PHP core that other features hook into to function. This core is easily extensible and the new structure of a main project with many smaller projects will make bugfixes and upgrades less painful, and will allow the user to upgrade the plugin section by section as most changes in the modules won&#8217;t effect the core. </p>
<p>For the users:</p>
<ol>
<li>INAP 3.0 will make upgrades far less painful. With each section managing its own options there won&#8217;t be the constant changes to the way little things work.</li>
<li>Features will flow more freely, and individual sections will reach maturity faster.<br />
Individual modules can be deleted without effecting the rest of the plugin. his will help speed up your WP.</li>
<li>Most bugs and irritants in the current version of INAP have been removed including the entire reload of the comments section when a comment is posted, the extra text added to links has been minimized, the built in effects have been improved, and the entire plugin is faster and easy to use.</li>
</ol>
<p>For the developers:</p>
<ol>
<li>INAP 3.0 core now works off of advanced PHP/Javascript/XML and can easily be extended with custom modules. </li>
<li>The new license is less restrictive that the previous versions.</li>
<li>INAP 3.0 provides a framework that other plugins can hook into to harness its maturity and the hundreds of hours that have gone in to its development. </li>
<li>Global variables have been almost entirely eliminated from both the Javascript and PHP&#8212;INAP 3.0 will play nice.</li>
<li>The Javascript core is entirely independent of the AJAX library used which means that any AJAX library (jQuery, Prototype, Mootools, etc) can be used and and INAP 3.0 will function just as well. Adding new libraries is no harder than adding a couple lines of code.</li>
<li>A few well placed actions and template files can make any theme compatible.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/wordpress/plugins/inap-30-progress.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>INAP and feed problems</title>
		<link>http://anthologyoi.com/news-briefs/inap-and-feed-problems.html</link>
		<comments>http://anthologyoi.com/news-briefs/inap-and-feed-problems.html#comments</comments>
		<pubDate>Sun, 29 Jul 2007 02:34:18 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[bugfix]]></category>
		<category><![CDATA[excerpt]]></category>
		<category><![CDATA[feeds]]></category>
		<category><![CDATA[INAP]]></category>
		<category><![CDATA[Plugins]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/news-briefs/inap-and-feed-problems.html</guid>
		<description><![CDATA[If you use INAP and have noticed oddness with your full-text feeds lately, it may have been caused by INAP. Users that had the &#8220;custom options&#8221; selected would have their feeds trimmed as if it were a post. INAP 2.4.3 &#8230; <a href="http://anthologyoi.com/news-briefs/inap-and-feed-problems.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you use <a href="http://anthologyoi.com/inap/">INAP</a> and have noticed oddness with your full-text feeds lately, it may have been caused by INAP. Users that had the &#8220;custom options&#8221; selected would have their feeds trimmed as if it were a post. INAP <a href="http://downloads.wordpress.org/plugin/inline-ajax-page.2.4.3.zip">2.4.3</a> fixes this.</p>
<p>In other news, INAP is in the process of a major overhaul including a complete rewrite of most of its antiquated structure. When this process is complete it will be rebranded to demonstrate the totality of its features (it won&#8217;t be called INAP anymore because the name is too restrictive), but will be released as version 3.0</p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/news-briefs/inap-and-feed-problems.html/feed</wfw:commentRss>
		<slash:comments>57</slash:comments>
		</item>
		<item>
		<title>INAP listed on Mashable</title>
		<link>http://anthologyoi.com/news-briefs/inap-listed-on-mashable.html</link>
		<comments>http://anthologyoi.com/news-briefs/inap-listed-on-mashable.html#comments</comments>
		<pubDate>Sun, 22 Jul 2007 18:58:32 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[excerpt]]></category>
		<category><![CDATA[INAP]]></category>
		<category><![CDATA[Plugins]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/news-briefs/inap-listed-on-mashable.html</guid>
		<description><![CDATA[Inline Ajax Page was listed on Mashable as one of &#8220;30 good [AJAX wordpress plugins].&#8221; While I&#8217;m thankful for the publicity (it seems half the internet is scraping Mashable&#8217;s feed which resulted in a huge Technorati boost), as always, it &#8230; <a href="http://anthologyoi.com/news-briefs/inap-listed-on-mashable.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Inline Ajax Page was listed on Mashable as one of &#8220;<a href="http://mashable.com/2007/07/20/ajax-wordpress/">30 good [AJAX wordpress plugins]</a>.&#8221; While I&#8217;m thankful for the publicity (it seems half the internet is scraping Mashable&#8217;s feed which resulted in a huge Technorati boost), as always, it was described as &#8220;Allow[ing] readers to see a snippet of a post, click a button and the remainder will appear without going to another page.&#8221;</p>
<p>I almost cried. That description fits only the 1.0 version of INAP that was released over a year ago&#8211;now it does so much more than that that it is almost like saying Google is just a search engine. Oh well,  the traffic generated was good quality.</p>
<p>In other news, version 2.4.25 was released a couple days ago to fix a bug that occurs when submitting a comment using the jQuery library under IE6. I think bugfixes this specific really showcase how mature the plugin has become, so if you have used it in the past, but stopped because of bugs, why not try it again?</p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/news-briefs/inap-listed-on-mashable.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>INAP 2.4 is Live</title>
		<link>http://anthologyoi.com/news-briefs/inap-24-is-live.html</link>
		<comments>http://anthologyoi.com/news-briefs/inap-24-is-live.html#comments</comments>
		<pubDate>Fri, 13 Jul 2007 16:05:16 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[excerpt]]></category>
		<category><![CDATA[INAP]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://anthologyoi.com/news-briefs/inap-24-is-live.html</guid>
		<description><![CDATA[On this lovely Friday the 13th, Inline Ajax Page version 2.4 has finally been released. If you are upgrading or have ever installed INAP before follow the upgrade instructions here. Please report bugs as soon as you find them, as &#8230; <a href="http://anthologyoi.com/news-briefs/inap-24-is-live.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>On this lovely Friday the 13th, Inline Ajax Page version 2.4 has finally been released. </p>
<p><strong>If you are upgrading or have ever installed INAP before follow the <a href="http://anthologyoi.com/inap/inline-ajax-page-readme/#upgrading"> upgrade instructions here.</a></strong></p>
<p>Please report bugs as soon as you find them, as I will be making bug-fixing releases as they are fixed.</p>
<p>I am also specifically asking for feature ideas for the next version, so drop a note on the main page if you have any.</p>
]]></content:encoded>
			<wfw:commentRss>http://anthologyoi.com/news-briefs/inap-24-is-live.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

