<?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>Joe Junkin &#187; Ajax</title>
	<atom:link href="http://joe.junkin.com/tag/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://joe.junkin.com</link>
	<description>Life as it happens</description>
	<lastBuildDate>Thu, 14 Jan 2010 23:34:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Problems using YUI Panel</title>
		<link>http://joe.junkin.com/2008/03/28/problems-using-yui-panel/</link>
		<comments>http://joe.junkin.com/2008/03/28/problems-using-yui-panel/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 20:11:55 +0000</pubDate>
		<dc:creator>jjunkin</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[yui]]></category>
		<category><![CDATA[Modal Dialog]]></category>

		<guid isPermaLink="false">http://joe.junkin.com/?p=54</guid>
		<description><![CDATA[I use quite a few YUI panel objects as inline popups used for gathering and displaying information. Using the modal dialog option caused an IE error message: ‘A script on this page is causing Internet Explorer to run slowly …’ which caused me great worry until I discovered the cause and fix. I also had [...]]]></description>
			<content:encoded><![CDATA[<p>I use quite a few YUI panel objects as inline popups used for gathering and displaying information. Using the modal dialog option caused an IE error message: ‘A script on this page is causing Internet Explorer to run slowly …’ which caused me great worry until I discovered the cause and fix. I also had issues with KeyListener events being executed after a dialog had been closed. Finally, finding when to initialize the dialogs was a challenge. <span> </span></p>
<p class="MsoNormal"><span id="more-36"></span></p>
<p class="MsoNormal">I began getting the IE error message:</p>
<p class="MsoNormal">&#8220;Stop running the script? A script on this page is causing Internet<br />
Explorer to run slowly. If it continues to run, your computer may become<br />
unresponsive.&#8221;</p>
<p class="MsoNormal">Which was scary as I thought this was due to the amount of data I was loading into javscript arrays and my dynamic DOM events. The errors were continuous and appeared to occur after one or more of the YUI panels were displayed in modal mode. When I limited the amount of data being processed, the errors continued. I figured there must be something wrong with my code.</p>
<p class="MsoNormal">
<p class="MsoNormal">After many google searches on the error message, I found this link about a bug in the YUI panel in modal mode with complex pages:</p>
<p class="MsoNormal"><a href="http://sourceforge.net/tracker/index.php?func=detail&amp;aid=1884118&amp;group_id=165715&amp;atid=836476">http://sourceforge.net/tracker/index.php?func=detail&amp;aid=1884118&amp;group_id=165715&amp;atid=836476</a></p>
<p class="MsoNormal">
<p class="MsoNormal">It appears that the YUI panel in modal mode is not scalable:</p>
<p class="MsoNormal">
<pre>“The currently implementation, which attaches focus handlers (which blur) to all focus'able items on the page when modal, definitely has scalability issues.”</pre>
<p class="MsoNormal">
<p class="MsoNormal">Thanks for letting me know guys! I just spent hours trying to figure out what was wrong with my code! It would be nice of them to put a note about this on the YUI webpage for the panel object.</p>
<p class="MsoNormal">The solution is to unsubscribe the listeners</p>
<pre>dialog.showMaskEvent.unsubscribe();</pre>
<pre>dialog.hideMaskEvent.unsubscribe();</pre>
<p class="MsoNormal">This degrades the modality a bit by still allowing the user to TAB into the page behind the mask and launch links, but they cannot click with the mouse. Good enough functionality for me.</p>
<p class="MsoNormal">
<p class="MsoNormal">I also had issues where events were being fired when the enter key was pressed. It seemed that the event from a closed dialog was being launched along with the currently open dialog’s key event. Unfortunately, it’s hard to pin down how this was fixed or why it was happening. I fiddled a bit and it seems fine now.</p>
<p class="MsoNormal">
<p class="MsoNormal">The final issue I had was when to initialize the panels. I started by using the YUI suggested method of using the YAHOO.util.Event.addListener <span> </span>method. The problem was that I already had a function running &lt;body onLoad() which would sometimes call the panel routines. This would cause an error if the panel had not been initialized. I could not find any method for prioritizing when the events would run.</p>
<p class="MsoNormal">I finally just called the routines in my &lt;body onLoad() routine to ensure that the panels were initialized before they were needed. This seems to work fine.</p>
]]></content:encoded>
			<wfw:commentRss>http://joe.junkin.com/2008/03/28/problems-using-yui-panel/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Strange server errors posting an Ajax form</title>
		<link>http://joe.junkin.com/2008/03/26/issues-posting-a-form-using-ajax/</link>
		<comments>http://joe.junkin.com/2008/03/26/issues-posting-a-form-using-ajax/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 21:50:25 +0000</pubDate>
		<dc:creator>jjunkin</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[server error]]></category>
		<category><![CDATA[yui]]></category>

		<guid isPermaLink="false">http://joe.junkin.com/2008/03/26/issues-posting-a-form-using-ajax/</guid>
		<description><![CDATA[I just wrestled with getting a form to post via ajax. I have done this before but had a bunch of issues crop up this time including strange intermitten server errors that only seemed to occur on Firefox. I resolved it by using the extremely handy YUI connection manager &#8217;setForm&#8217; function to process the data for me. [...]]]></description>
			<content:encoded><![CDATA[<p>I just wrestled with getting a form to post via ajax. I have done this before but had a bunch of issues crop up this time including strange intermitten server errors that only seemed to occur on Firefox. I resolved it by using the extremely handy YUI connection manager &#8217;setForm&#8217; function to process the data for me. I also found a problem when submitting a non-rails created form that caused an ctionController::InvalidAuthenticityToken error.</p>
<p><span id="more-35"></span></p>
<p>I was sending the form by using a javascript function to get each field, concatonate a url (using escape) and use the YUI connection manager with a GET method. This caused intermitten errors on firefox including one like &#8216;the server did not understand the request&#8217; (or something like that). What was happening was the escape was creating a series of chars that triggered a mod_security rule. The rule was blocking access to the rails server.</p>
<p><code>ModSecurity: Access denied with code 400 (phase 2). Pattern match "%0[ad]" at REQUEST_URI. [id "950910"] [msg "HTTP Response Splitting Attack. Matched signature &lt;%0a&gt;"] [severity "ALERT"] [hostname "dev.removed.com"] [uri "/aSubmitContact?name=john%20johnson&amp;email=john@removed.com&amp;phone=123455&amp;msg=this%20is%20a%20test%0Athsi%20is%20only%20a%20test&amp;subject=general"]<br />
</code></p>
<p>I did some digging and discovered that YUI has a sweet function to fetch, prepare and send the form fields for me:</p>
<p><code>Connection Manager can automatically harvest HTML form data and prepare it for either a GET or POST request via the setForm method. When you call this method before initiating the transaction, Connection Manager constructs a GET querystring or a POST message from the form and submits it to the specified URL.</code></p>
<p>You simply hand the element to <code>YAHOO.util.Connect.setForm(formObject, true); </code>and the connection manager takes care of the rest. SWEET!</p>
<p>After that, another issue came up with rails. It seems that rails expects you to utilize it&#8217;s built-in form generator. When I submitted the form I built with javascript using the DOM, I got the error:</p>
<p><code>ActionController::InvalidAuthenticityToken</code></p>
<p>This appears to be due to a new feature in rails that attempts to stop cross-site-scripting by attaching an hidden identifier value to the form. I had to disable the feature for my javascript created form. To disable it I used:<br />
<code>protect_from_forgery <img src='http://joe.junkin.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> nly =&gt; [:update, :delete, :create].</code><br />
I realize that it is a nice feature, but it would be nice to see it as optional instead of default.</p>
]]></content:encoded>
			<wfw:commentRss>http://joe.junkin.com/2008/03/26/issues-posting-a-form-using-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
