<?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>FerretArmy: A Web Developer&#039;s Paradise &#187; Ajax</title>
	<atom:link href="http://www.ferretarmy.com/category/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ferretarmy.com</link>
	<description>Pushing the Web Forward, Since 2007</description>
	<lastBuildDate>Wed, 18 Jan 2012 15:58:58 +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>jQuery Templating with .tmpl</title>
		<link>http://www.ferretarmy.com/2011/06/01/jquery-templating-with-tmpl/</link>
		<comments>http://www.ferretarmy.com/2011/06/01/jquery-templating-with-tmpl/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 00:27:23 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[WebDev]]></category>

		<guid isPermaLink="false">http://www.ferretarmy.com/?p=544</guid>
		<description><![CDATA[A quick overview of the jQuery templating API.]]></description>
			<content:encoded><![CDATA[<p>Templating of web controls is a valuable technique that allows for code reuse. For example, if you have a repeated list of items with common attributes that need to be displayed on a web page, templating is a great solution. Templating can often be accomplished on the server side through controls such as ASP.NET repeaters. However, with the web of today, asynchronous programming is where it&#8217;s at. With AJAX data calls, you often get JSON objects back that must be turned into HTML and displayed on a web page.</p>
<p>There are a few ways of doing so &#8211; you could have an asynchronous call return an HTML fragment, for instance (done that). You could also embed placeholders in hidden HTML fragments on a page, and use a combination of jQuery&#8217;s clone/replace/append methods to push object data into them (done that too). However, there&#8217;s an even better technique available now, as a first-class citizen in the jQuery library &#8211; the <a href="http://api.jquery.com/jquery.tmpl/">.tmpl templating API</a>.</p>
<p>jQuery templating is a feature that&#8217;s currently in beta (though it is distributed with jQuery as of version 1.4.3), and is based upon an <a href="https://github.com/jquery/jquery-tmpl">existing templating plugin</a>. I&#8217;ve had the pleasure of using the jQuery templating API for a bit of time now, and I admit that it is by far the easiest, most robust templating solution I&#8217;ve found. There are template controls for repeaters (<a href="http://api.jquery.com/template-tag-each">{{each}}</a>), conditional statements (<a href="http://api.jquery.com/template-tag-if/">{{if}}</a> and <a href="http://api.jquery.com/template-tag-else">{{else}}</a>), templated HTML fragments (<a href="http://api.jquery.com/template-tag-html">{{html}}</a>), and wrapping (<a href="http://api.jquery.com/template-tag-wrap">{{wrap}}</a>). That&#8217;s a lot of functionality out of the box!</p>
<p>By far my favorite part of html templating, however, is the &lt;script type=&#8217;text/x-jquery-tmpl&#8217;&gt;&lt;/script&gt; tagging that you can wrap around your template fragments. One thing I&#8217;ve disliked with templating is that you have to embed potentially malformed HTML into your page &#8211; for instance, you might end up having to template id attributes. Malformed html is not the worst thing in the world, especially in hidden fields, but it certainly doesn&#8217;t help with search engine rankings and such. Having a way of clearly saying &#8220;I&#8217;m a template fragment&#8221; is a great thing, both for search engines and general maintainability.</p>
<p>If you haven&#8217;t gotten a chance to take a look at jQuery templating, now is certainly a great time to do so. It comes for free with jQuery, and it&#8217;s a fast, easy, and robust solution for templating needs.</p>
<div id="_mcePaste" class="mcePaste" style="position: absolute; left: -10000px; top: 116px; width: 1px; height: 1px; overflow: hidden;"><code>text/x-jquery-tmpl</code></div>
]]></content:encoded>
			<wfw:commentRss>http://www.ferretarmy.com/2011/06/01/jquery-templating-with-tmpl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Ajax Beats ASP.NET Ajax</title>
		<link>http://www.ferretarmy.com/2009/06/04/jquery-ajax-beats-aspnet-ajax/</link>
		<comments>http://www.ferretarmy.com/2009/06/04/jquery-ajax-beats-aspnet-ajax/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 17:50:32 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Geeky]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[WebDev]]></category>
		<category><![CDATA[ASP.NET Ajax]]></category>

		<guid isPermaLink="false">http://www.ferretarmy.com/?p=338</guid>
		<description><![CDATA[ASP.NET Ajax is a good technology in theory, but the implementation in practice is anything but smooth. There are many little &#8216;quirks&#8217; that ASP.NET Ajax does to your page; these quirks almost entirely revolve around the handling of viewstate during ajax calls. ASP.NET Ajax passes the viewstate to the server and back during things like [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.asp.net/ajax/">ASP.NET Ajax</a> is a good technology in theory, but the implementation in practice is anything but smooth. There are many little &#8216;quirks&#8217; that ASP.NET Ajax does to your page; these quirks almost entirely revolve around the handling of <a href="http://msdn.microsoft.com/en-us/library/ms972976.aspx">viewstate</a> during ajax calls.</p>
<p>ASP.NET Ajax passes the viewstate to the server and back during things like <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel.aspx">UpdatePanel</a> updates. This is done to insure that the viewstate is always up to date, even if the page information changes during the Ajax call. Many Ajax calls, however, don&#8217;t require any changes to viewstate. Unfortunately, when the viewstate comes back, I&#8217;ve found many unpredictable results &#8211; things like page titles changing and breaks in back-button functionality in some scenarios. More importantly, these bugs are hard to track down and understand, in my experience. On top of this, viewstate is usually pretty large, which slows down ASP.NET Ajax requests and transfers more data across the wire, increasing bandwidth costs.</p>
<p>What have I chosen to do instead? Through <a href="http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/">Encosia</a>, I&#8217;ve found that it&#8217;s fairly trivial to make <a href="http://jquery.com/">jQuery</a> Ajax calls into the codebehind, or even to local web services via <a href="http://www.json.org/">JSON</a>. These calls are small (they don&#8217;t send viewstate), transparent (they don&#8217;t change page information on return unless you explicitly ask to), cross-browser compatible, and rock-solid (like everything in jQuery).</p>
<p>Surely there are quite a few circumstances where ASP.NET Ajax beats out jQuery Ajax (for things like datagrid population, for example). From now on, though, I&#8217;ve decided that my default stance will be to write my Ajax calls in jQuery unless I can create a compelling case to do so in another technology.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ferretarmy.com/2009/06/04/jquery-ajax-beats-aspnet-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery and Visual Studio</title>
		<link>http://www.ferretarmy.com/2008/10/06/jquery-and-visual-studio/</link>
		<comments>http://www.ferretarmy.com/2008/10/06/jquery-and-visual-studio/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 00:30:17 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Geeky]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Microsoft Visual Studio]]></category>

		<guid isPermaLink="false">http://www.ferretarmy.com/?p=132</guid>
		<description><![CDATA[Did you get the chance to read that Visual Studio will be shipping with jQuery support included in the future? This news just made my day, more or less. If you aren&#8217;t in the know, jQuery is a really well developed JavaScript framework library. It includes support for things like making AJAX requests, easy DOM [...]]]></description>
			<content:encoded><![CDATA[<p>Did you get the chance to read that <a href="http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx">Visual Studio will be shipping with jQuery support included</a> in the future? This news just made my day, more or less. If you aren&#8217;t in the know, <a href="http://jquery.com/">jQuery</a> is a really well developed JavaScript framework library. It includes support for things like making AJAX requests, easy DOM manipulation, and effects. There are a significant amount of <a href="http://www.ajaxrain.com">controls</a> written on top of jQuery that provide rich web experiences, and are as simple to use as integrating a plugin and adding markup to your HTML. The best part is that the use of a JavaScript framework has huge beneficial aspects on your cross-browser capabilities &#8211; all the framework methods are more or less guaranteed to work on everything from IE6 to Chrome!</p>
<p>Visual Studio ships with ASP.NET AJAX, which is kind of like the Microsoft bastardized attempt at a JavaScript framework. It&#8217;s been lagging behind jQuery and most other modern JavaScript frameworks since it&#8217;s introduction. Now, with full jQuery support, including intellisense, there&#8217;s little reason to have to use ASP.NET AJAX, in my opinion.</p>
<p>The one unfortunate aspect of official jQuery support in Visual Studio is that there are a lot of other competing frameworks, many of which are on par with jQuery, but whose market share will inevitably erode. Either way, a choice had to be made in this regard, and the right one was, in my opinion.</p>
<p>JavaScript can provide such a rich user experience nowadays that it rivals <a href="http://www.adobe.com/products/air/">Flash/Air</a> and <a href="http://silverlight.net/">Silverlight</a> in many areas. It&#8217;s also getting faster (on a daily basis, seemingly), which bodes well for it&#8217;s future. If you haven&#8217;t checked out jQuery up to this point, it&#8217;s well worth a minute of your time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ferretarmy.com/2008/10/06/jquery-and-visual-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Art of Web Development</title>
		<link>http://www.ferretarmy.com/2008/03/14/the-art-of-web-development/</link>
		<comments>http://www.ferretarmy.com/2008/03/14/the-art-of-web-development/#comments</comments>
		<pubDate>Fri, 14 Mar 2008 12:54:19 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.ferretarmy.com/2008/03/14/the-art-of-web-development/</guid>
		<description><![CDATA[I&#8217;ve been playing around with a few freely available Javascript libraries as of late, and I&#8217;ve been so very impressed at the quality and ease of use of what&#8217;s out there. I&#8217;m sure that most web developers are fairly well versed in the art, but since my career took a slightly different path until late, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing around with a few freely available Javascript libraries as of late, and I&#8217;ve been so very impressed at the quality and ease of use of what&#8217;s out there. I&#8217;m sure that most web developers are fairly well versed in the art, but since my career took a slightly different path until late, I&#8217;ve missed the proverbial boat and have some catching up to do. As far as technology, I&#8217;ve been particularly impressed with the <a href="http://www.prototypejs.org">prototype</a> library, <a href="http://script.aculo.us/">script.aculo.us</a>, the <a href="http://livepipe.net/projects/control_suite/">control suite</a> from livepipe, <a href="http://www.nickstakenburg.com/projects/lightview">lightview</a>, and a lot of the stuff on <a href="http://www.ajaxrain.com">ajax rain</a>. The people that make these libraries are incredible &#8211; very professional, dedicated, and willing to give their work freely to the community at large.</p>
<p>This site is hosted using <a href="http://www.wordpress.org">WordPress</a> as the engine. What I hadn&#8217;t realized until late is that the platform actually uses a lot of these tools already. The state of these free tools allows rapid prototyping and development of websites that have extremely valuable functionality built in. This differs so much from just a few years ago, when the best tools available were tutorials and maybe a few pieces of css or javascript that would need to be largely rewritten on a per-application basis. What a great and exciting time to be a web developer!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ferretarmy.com/2008/03/14/the-art-of-web-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disabling an Ajax Timer Control</title>
		<link>http://www.ferretarmy.com/2008/01/02/disabling-an-ajax-timer-control/</link>
		<comments>http://www.ferretarmy.com/2008/01/02/disabling-an-ajax-timer-control/#comments</comments>
		<pubDate>Wed, 02 Jan 2008 21:25:17 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Geeky]]></category>

		<guid isPermaLink="false">http://www.ferretarmy.com/2008/01/02/disabling-an-ajax-timer-control/</guid>
		<description><![CDATA[I just got done fixing an issue that I was having with the ASP.NET AJAX Timer control, and I figured I&#8217;d write about it because there doesn&#8217;t seem to be like a ton of documentation out there right now as to exactly what is going on. Here is the scenario: You have an Ajax enabled [...]]]></description>
			<content:encoded><![CDATA[<p>I just got done fixing an issue that I was having with the ASP.NET AJAX Timer control, and I figured I&#8217;d write about it because there doesn&#8217;t seem to be like a ton of documentation out there right now as to exactly what is going on.</p>
<p>Here is the scenario: You have an Ajax enabled .aspx page which has an UpdatePanel set to update itself based upon a timed interval from a Timer control. You also have some type of submit button on the page that does a synchronous page submission. So, what happens when you click on the submit button, and before the page submit has run through it&#8217;s logic, the timer control trips and causes an asynchronous Ajax post? Well, what I was seeing was that the page would end up in an incongruous state &#8211; the submit works, but the page updates itself to show the results of the asynchronous update, not of the synchronous submit action.</p>
<p>This behavior is to be expected, to tell the truth. One of the actions has to win, and it may as well be the last one into the queue instead of the first. So, the real thing we want to do is disable the timer control based upon the submit button being clicked. No problem, I thought &#8211; I&#8217;ll just disable it in the event handler for the button click, like this:</p>
<blockquote><p><font size="2"><font color="#0000ff">private void</font> SomeButton_Click(<font color="#0000ff">object</font> sender, <font color="#2b91af">EventArgs</font> e){</font><font size="2"></p>
<blockquote><p>Timer1.Enabled = false();</p>
<p><font color="#008000">// Do stuff here&#8230;</font></p>
<p><font color="#008000">// Maybe reenable the timer here&#8230;</font></p></blockquote>
<p>}</p>
<p></font></p></blockquote>
<p>Hmmm&#8230; that doesn&#8217;t seem to work, and here&#8217;s why. Since the submit button click is handled server-side, the enabling-disabling action won&#8217;t be propagated back to the client until the postback is complete. The timer is a client-side javascript control, so it can (and will) keep working as the page is being posted.</p>
<p>So, what do you do? Well, you&#8217;re only really left with one option &#8211; disable the timer control on the client side. That means you&#8217;re going to be doing it via Javascript. Luckily, I found <a href="http://disturbedbuddha.wordpress.com/2007/11/26/controlling-the-aspnet-timer-control-with-javascript/">this post</a> that details all about using Javascript to disable the timer control. Now, all you have to do is hook up a client side event to the timer control and programatically disable it. You can re-enable it in codebehind with the button click handler, too, so you don&#8217;t have to do that on the client side. Here&#8217;s what I ended up with:</p>
<blockquote><p><font size="2" color="#0000ff">&lt;<font color="#a31515">script</font> <font color="#ff0000">language</font><font color="#0000ff">=&#8221;javascript&#8221; </font><font color="#ff0000">type</font><font color="#0000ff">=&#8221;text/javascript&#8221;&gt;</font></font><br />
<font size="2" color="#0000ff">&lt;!&#8211;</font><br />
<font size="2" color="#0000ff">function DisableTimerControl(){ </font><font size="2" color="#0000ff"></p>
<blockquote><p><font color="#008000">// Disable the ajax timer control before elevating on the client side.</font><br />
<font color="#008000">// It will be re-enabled on the server side.</font><br />
<font size="2" color="#0000ff">var timerControl = $find(</font><font color="#a31515">&#8220;AjaxUpdateTimer&#8221;</font>);</p>
<p><font size="2"><font color="#0000ff">if</font> (timerControl != <font color="#0000ff">null</font>){ </font><font size="2"></p>
<blockquote><p>timerControl._stopTimer();</p></blockquote>
<p>}<br />
<font color="#0000ff">return</font> true;</p>
<p></font></p></blockquote>
<p>}<br />
&#8211;&gt;<br />
<font color="#0000ff">&lt;/</font><font color="#a31515">script</font><font color="#0000ff">&gt;</font></p>
<p></font></p></blockquote>
<p>That wasn&#8217;t so bad, was it now? The long and the short of it is that you have to be careful about using Ajax controls, but it is still pretty easy to make them do what you want if you&#8217;re on top of things. Either way, Ajax is here to stay, so get used to it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ferretarmy.com/2008/01/02/disabling-an-ajax-timer-control/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

