<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Defensive AJAX and AJAX retries in jQuery</title>
	<atom:link href="http://zeroedandnoughted.com/defensive-ajax-and-ajax-retries-in-jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://zeroedandnoughted.com/defensive-ajax-and-ajax-retries-in-jquery/</link>
	<description>0000000000000000000000000000000000</description>
	<lastBuildDate>Tue, 05 Jul 2011 12:09:22 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
	<item>
		<title>By: booshtukka</title>
		<link>http://zeroedandnoughted.com/defensive-ajax-and-ajax-retries-in-jquery/#comment-2409</link>
		<dc:creator>booshtukka</dc:creator>
		<pubDate>Tue, 23 Nov 2010 14:54:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.zeroedandnoughted.com/?p=185#comment-2409</guid>
		<description>Thanks, I&#039;ll take a look.</description>
		<content:encoded><![CDATA[<p>Thanks, I&#8217;ll take a look.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark van Wyk</title>
		<link>http://zeroedandnoughted.com/defensive-ajax-and-ajax-retries-in-jquery/#comment-2065</link>
		<dc:creator>Mark van Wyk</dc:creator>
		<pubDate>Wed, 10 Nov 2010 18:32:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.zeroedandnoughted.com/?p=185#comment-2065</guid>
		<description>This does not (as yet) work in JQuery 1.4.3</description>
		<content:encoded><![CDATA[<p>This does not (as yet) work in JQuery 1.4.3</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark van Wyk</title>
		<link>http://zeroedandnoughted.com/defensive-ajax-and-ajax-retries-in-jquery/#comment-2064</link>
		<dc:creator>Mark van Wyk</dc:creator>
		<pubDate>Wed, 10 Nov 2010 18:25:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.zeroedandnoughted.com/?p=185#comment-2064</guid>
		<description>This looks like a fantastic idea but for some odd reason, I&#039;m getting a too much recursion error. Any ideas?

		$.ajax ({
			url: url,
			data: data,
			timeout: 2000,
			requestId: model.requestId,
			tryCount: 0,
			retryLimit: 4,
			success: function(data) {
				controller.log(&quot;Request &quot; + this.requestId + &quot; success.&quot;);
				fn_success(data);
				return;
			},
			error: function(xhr, status, ex) {
				if (status == &#039;error&#039; &amp;&amp; xhr.status == 404) {
					controller.log (&quot;Request &quot; + this.requestId + &quot; failed for good.&quot;);
					fn_error();
					return;
				}
				this.tryCount++;
				if (this.tryCount &lt;= this.retryLimit) {
					controller.log (&quot;Request &quot; + this.requestId + &quot; failed. Trying &quot; + this.tryCount + &quot; time.&quot;);
					controller.log(this);
					$.ajax(this);
					return;
				} else {
					controller.log (&quot;Request &quot; + this.tryCount)
					fn_error();
					return;
				}
			}
		});</description>
		<content:encoded><![CDATA[<p>This looks like a fantastic idea but for some odd reason, I&#8217;m getting a too much recursion error. Any ideas?</p>
<p>		$.ajax ({<br />
			url: url,<br />
			data: data,<br />
			timeout: 2000,<br />
			requestId: model.requestId,<br />
			tryCount: 0,<br />
			retryLimit: 4,<br />
			success: function(data) {<br />
				controller.log(&#8220;Request &#8221; + this.requestId + &#8221; success.&#8221;);<br />
				fn_success(data);<br />
				return;<br />
			},<br />
			error: function(xhr, status, ex) {<br />
				if (status == &#8216;error&#8217; &amp;&amp; xhr.status == 404) {<br />
					controller.log (&#8220;Request &#8221; + this.requestId + &#8221; failed for good.&#8221;);<br />
					fn_error();<br />
					return;<br />
				}<br />
				this.tryCount++;<br />
				if (this.tryCount &lt;= this.retryLimit) {<br />
					controller.log (&quot;Request &quot; + this.requestId + &quot; failed. Trying &quot; + this.tryCount + &quot; time.&quot;);<br />
					controller.log(this);<br />
					$.ajax(this);<br />
					return;<br />
				} else {<br />
					controller.log (&quot;Request &quot; + this.tryCount)<br />
					fn_error();<br />
					return;<br />
				}<br />
			}<br />
		});</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: philk</title>
		<link>http://zeroedandnoughted.com/defensive-ajax-and-ajax-retries-in-jquery/#comment-1173</link>
		<dc:creator>philk</dc:creator>
		<pubDate>Tue, 21 Sep 2010 23:03:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.zeroedandnoughted.com/?p=185#comment-1173</guid>
		<description>there seems to be a problem when using timeout in this code:
ajaxEx: function(settings, urls) {
    var originalErrorFunc = settings.error;
    var succeeded = false;
    var result;
    var urls = (settings.url instanceof Array) ? settings.url : [settings.url];
    //settings.mode = &#039;sync&#039;;    
    settings.error = function(xhr, status, error) {
      var url = urls.shift();
      //alert(&quot;Failed: &quot; + settings.url +  &quot;\nStatus: &quot; + status + &quot;\n&quot; + error + &quot;\nNext: &quot; + url);
      if (url) {
        settings.url = url;
        $.ajax(settings);
      } else if (originalErrorFunc) {
        originalErrorFunc.apply(settings, arguments);
      }
    };
    settings.url = urls.shift();
    $.ajax(settings);   
  }

you would call the function like $.ajaxEx({url: []}); and a new url will be used for the next ajax call if the previous fails with an error. However, the first error is most likely &quot;parsererror&quot; when loading xml data. The second error reported will be timeout.</description>
		<content:encoded><![CDATA[<p>there seems to be a problem when using timeout in this code:<br />
ajaxEx: function(settings, urls) {<br />
    var originalErrorFunc = settings.error;<br />
    var succeeded = false;<br />
    var result;<br />
    var urls = (settings.url instanceof Array) ? settings.url : [settings.url];<br />
    //settings.mode = &#8216;sync&#8217;;<br />
    settings.error = function(xhr, status, error) {<br />
      var url = urls.shift();<br />
      //alert(&#8220;Failed: &#8221; + settings.url +  &#8220;\nStatus: &#8221; + status + &#8220;\n&#8221; + error + &#8220;\nNext: &#8221; + url);<br />
      if (url) {<br />
        settings.url = url;<br />
        $.ajax(settings);<br />
      } else if (originalErrorFunc) {<br />
        originalErrorFunc.apply(settings, arguments);<br />
      }<br />
    };<br />
    settings.url = urls.shift();<br />
    $.ajax(settings);<br />
  }</p>
<p>you would call the function like $.ajaxEx({url: []}); and a new url will be used for the next ajax call if the previous fails with an error. However, the first error is most likely &#8220;parsererror&#8221; when loading xml data. The second error reported will be timeout.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jintu</title>
		<link>http://zeroedandnoughted.com/defensive-ajax-and-ajax-retries-in-jquery/#comment-837</link>
		<dc:creator>Jintu</dc:creator>
		<pubDate>Wed, 01 Sep 2010 06:52:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.zeroedandnoughted.com/?p=185#comment-837</guid>
		<description>Really worth to read this tutorial</description>
		<content:encoded><![CDATA[<p>Really worth to read this tutorial</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: booshtukka</title>
		<link>http://zeroedandnoughted.com/defensive-ajax-and-ajax-retries-in-jquery/#comment-39</link>
		<dc:creator>booshtukka</dc:creator>
		<pubDate>Mon, 19 Jul 2010 10:30:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.zeroedandnoughted.com/?p=185#comment-39</guid>
		<description>See the &lt;a href=&quot;http://api.jquery.com/jQuery.ajax/&quot; rel=&quot;nofollow&quot;&gt;jQuery AJAX documentation&lt;/a&gt;… It is for more information if it is available. I could safely have missed out this parameter, but it is useful in case we wanted to do something more &quot;real world&quot;.</description>
		<content:encoded><![CDATA[<p>See the <a href="http://api.jquery.com/jQuery.ajax/" rel="nofollow">jQuery AJAX documentation</a>… It is for more information if it is available. I could safely have missed out this parameter, but it is useful in case we wanted to do something more &#8220;real world&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben</title>
		<link>http://zeroedandnoughted.com/defensive-ajax-and-ajax-retries-in-jquery/#comment-38</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Fri, 09 Jul 2010 00:25:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.zeroedandnoughted.com/?p=185#comment-38</guid>
		<description>Excellent!!!! What is the errorThrown parameter used for though? It&#039;s not called anywhere?</description>
		<content:encoded><![CDATA[<p>Excellent!!!! What is the errorThrown parameter used for though? It&#8217;s not called anywhere?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aidan</title>
		<link>http://zeroedandnoughted.com/defensive-ajax-and-ajax-retries-in-jquery/#comment-37</link>
		<dc:creator>Aidan</dc:creator>
		<pubDate>Wed, 03 Feb 2010 12:41:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.zeroedandnoughted.com/?p=185#comment-37</guid>
		<description>Great tutorial. Too bad this blog isn&#039;t as active anymore. Can you get in touch with me as I could not locate your contact details. Thanks.</description>
		<content:encoded><![CDATA[<p>Great tutorial. Too bad this blog isn&#8217;t as active anymore. Can you get in touch with me as I could not locate your contact details. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gavin Williams</title>
		<link>http://zeroedandnoughted.com/defensive-ajax-and-ajax-retries-in-jquery/#comment-36</link>
		<dc:creator>Gavin Williams</dc:creator>
		<pubDate>Tue, 18 Aug 2009 09:50:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.zeroedandnoughted.com/?p=185#comment-36</guid>
		<description>Agree quite a bit, this is the reason why I hate to love implementing AJAX, &quot;fragile&quot; has to be the most accurate term for it, especially if the backend isn&#039;t as strong as the front end implementation, as it&#039;s quite often flakey!

Really nice post.</description>
		<content:encoded><![CDATA[<p>Agree quite a bit, this is the reason why I hate to love implementing AJAX, &#8220;fragile&#8221; has to be the most accurate term for it, especially if the backend isn&#8217;t as strong as the front end implementation, as it&#8217;s quite often flakey!</p>
<p>Really nice post.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

