<?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>AJAX Archives &#8211; hoech.net</title>
	<atom:link href="https://hoech.net/tag/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>https://hoech.net/tag/ajax/</link>
	<description>Webdesign und -entwicklung, professionelle Bildbearbeitung, Reinzeichnung, DTP und Prepress in Stuttgart</description>
	<lastBuildDate>Tue, 10 Dec 2013 18:36:44 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.5</generator>
	<item>
		<title>Custom tumblr 404 error page</title>
		<link>https://hoech.net/2013/12/10/custom-tumblr-404-error-page/</link>
		
		<dc:creator><![CDATA[Florian Höch]]></dc:creator>
		<pubDate>Tue, 10 Dec 2013 13:52:02 +0000</pubDate>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[Web-Entwicklung]]></category>
		<category><![CDATA[404]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[tumblr]]></category>
		<guid isPermaLink="false">http://hoech.net/?p=616</guid>

					<description><![CDATA[<p>I wanted to have a custom 404 page for a client project, but tumblr does not have the ability to define a custom style or even custom content for the 404 error page. There are some ways around this, but [&#8230;] <a href="https://hoech.net/2013/12/10/custom-tumblr-404-error-page/" class="more-link"><span class="meta-nav">Weiterlesen &#8594;</span></a></p>
<p>Der Beitrag <a href="https://hoech.net/2013/12/10/custom-tumblr-404-error-page/">Custom tumblr 404 error page</a> erschien zuerst bei <a href="https://hoech.net">hoech.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I wanted to have a custom 404 page for a client project, but tumblr does not have the ability to define a custom style or even custom content for the 404 error page. There are <a href="https://gist.github.com/karteek/260200">some ways around this</a>, but solutions like that have the problem that they do not really always work because they look for a certain error text in the page, but that error text is actually translated according to a visitor&#8217;s language preference (as set in their browser). The solution I came up with is to do an AJAX HTTP HEAD request via <a href="http://jquery.com/">jQuery</a> to the current document URL, and if that returns a 404 status code, forward to the custom 404 page (which is an actual custom page on the tumblr blog in question—you could also replace or alter the page content via JavaScript instead if you were so inclined). <span id="more-616"></span> Here&#8217;s the code:</p>
<pre class="language-javascript"><code>// Make a request to ourself to figure out if this returns a 404,
// and if that is the case, show our custom 404 page
$.ajax(document.location.href, {type: 'HEAD'}).fail(function (jqXHR, textStatus, errorThrown) {
	if (jqXHR.status == 404)
		location.href = document.location.protocol + '//' + document.domain + '/not-found';
});</code></pre>
<p>This still has the problem that it will briefly show the error page in the blog&#8217;s normal layout before the redirection occurs, also if the user navigates back they will end up being redirected again (this could be solved by using <code>location.replace</code>).</p>
<p><a href="http://typostrate.com/this-page-does-not-exist">Here you can see the solution in action</a>.</p>
<p>Der Beitrag <a href="https://hoech.net/2013/12/10/custom-tumblr-404-error-page/">Custom tumblr 404 error page</a> erschien zuerst bei <a href="https://hoech.net">hoech.net</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss><!-- hyper cache: hoech.net/tag/ajax/feed/index.dat 26-06-04 01:21:27 -->