<?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>Wysmedia.com &#187; ajax</title>
	<atom:link href="http://www.wysmedia.com/tag/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wysmedia.com</link>
	<description>~ We make IT easy for you ~</description>
	<lastBuildDate>Fri, 08 May 2009 07:02:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Trapping Server Error</title>
		<link>http://www.wysmedia.com/2009/02/trapping-server-error/</link>
		<comments>http://www.wysmedia.com/2009/02/trapping-server-error/#comments</comments>
		<pubDate>Sat, 14 Feb 2009 01:14:12 +0000</pubDate>
		<dc:creator>adwin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.wysmedia.comyr.com/?p=16</guid>
		<description><![CDATA[Sometimes we found that our server are not behave normal, like there are bugs or server produce runtime exception (or error 404 etc). Those exception are not returned by ajax. So it will keep hidden and seems nothing happened. But if you have firebug installed, you can found that there are errors happened from your [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes we found that our server are not behave normal, like there are bugs or server produce runtime exception (or error 404 etc). Those exception are not returned by ajax. So it will keep hidden and seems nothing happened. But if you have firebug installed, you can found that there are errors happened from your server.</p>
<p>So here is how you can trap all errors and displayed on your screen (without using firebug).</p>
<p>This example works on grails main layout (but you can use this tips on any programming language, just put this code on main layout). My code using Jquery and JQalert to display the error </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ajaxError</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #339933;">,</span> request<span style="color: #339933;">,</span> setting<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                    <span style="color: #003366; font-weight: bold;">var</span> re <span style="color: #339933;">=</span> <span style="color: #009966; font-style: italic;">/&amp;lt;br\/&amp;gt;|&amp;lt;br&amp;gt;/g</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// for replacing all &amp;lt;br/&amp;gt; with empty string in error 404</span>
                    <span style="color: #003366; font-weight: bold;">var</span> txt <span style="color: #339933;">=</span> request.<span style="color: #660066;">responseText</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span>re<span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    jqalert<span style="color: #009900;">&#40;</span>txt<span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;Server Error&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.wysmedia.com/2009/02/trapping-server-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script>
<noscript><a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/count.php" alt="web hosting" /></a></noscript>
<!-- End Of Analytics Code -->
