<?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>www.nerdscene.com &#187; JavaScript</title>
	<atom:link href="http://www.nerdscene.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nerdscene.com</link>
	<description>bitching about everything, one post at a time...</description>
	<lastBuildDate>Tue, 06 Apr 2010 17:40:42 +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>Internet Explorer 7 crashes when trying to submit a form?</title>
		<link>http://www.nerdscene.com/2009/05/05/115/</link>
		<comments>http://www.nerdscene.com/2009/05/05/115/#comments</comments>
		<pubDate>Tue, 05 May 2009 15:39:52 +0000</pubDate>
		<dc:creator>Eli Sand</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[MSDN]]></category>

		<guid isPermaLink="false">http://www.nerdscene.com/?p=115</guid>
		<description><![CDATA[As I was testing a recent site I had designed in Internet Explorer for compatibility, I came across one of the forms which was apparently causing Internet Explorer 7 to crash. It put a real damper on the testing since it was causing a crash which I would consider to be pretty heavy on the [...]]]></description>
			<content:encoded><![CDATA[<p>As I was testing a recent site I had designed in Internet Explorer for compatibility, I came across one of the forms which was apparently causing Internet Explorer 7 to crash.  It put a real damper on the testing since it was causing a <em>crash</em> which I would consider to be pretty heavy on the &#8220;must fix&#8221; list before it goes live.  The worst part was, I had done a lot of extensive testing with Firefox which showed no problems, and even Internet Explorer 8 was behaving as expected.  Thankfully I have Internet Explorer 8 which finally has a decent set of developer tools built in, so I set forth to try and figure out what the problem was&#8230; hopefully!</p>
<p>My first thought was that it might be some code I had recently added to a JavaScript file which was responsible for capturing the name/value pair of the submit button pressed when you submit a form (which is the only way to get that information when using AJAX to submit form data).  The code worked great in Firefox, but I hadn&#8217;t tested it yet for Internet Explorer at all, so I changed it around a bit to see if maybe some of that was causing it.  My debugging progressed to completely commenting out that new code, essentially bringing me back to code I knew worked in Internet Explorer 7 before, but it was <em>still</em> crashing!<br />
<span id="more-115"></span><br />
I started to dig a bit deeper and noticed that for some reason if I commented out one of my submit buttons (my form had two buttons with the same name &#8211; used to pick between two choices&#8230; both of which submit the form), it wouldn&#8217;t crash any more &#8211; but it wasn&#8217;t submitting the form via AJAX which it should have been, so there was still a problem somewhere.  Since I was able to get a bit further now that Internet Explorer 7 wasn&#8217;t crashing, I was able to determine that it was choking somewhere in jQuery, at a piece of code that quite simply just tried to toUpperCase() a string &#8211; namely the method of the form (that is, whether it was to be submitted via GET or POST).</p>
<p>I played around a bit and noticed that if I hard coded in (to my JavaScript code that builds the form data to be sent via AJAX) a method of &#8220;post&#8221;, that it worked fine &#8211; it didn&#8217;t like it when I tried to retrieve the method set on the form however.  After a bit more sleuthing, I decided to check up on the getAttribute() DOM function which I used to try and retrieve the form method.  What I found was a piece of gold buried under the usual <a href="http://msdn.microsoft.com/en-us/library/ms536429(VS.85).aspx" target="_blank">MSDN documentation</a>; someone had posted a comment at the bottom mentioning an obscure bug when using getAttribute on forms&#8230;  At first, I was a bit excited, hoping I had found the problem but I quickly saw that the bug was apparently just mentioning a problem when you used the name &#8220;id&#8221; on an input element which I was not doing in my code.  However, I kept reading the description and noticed there was an additional bit of information stating that the problem was that the name property on an input element could actually override any key word in the DOM, potentially causing odd behaviour.</p>
<p>I quickly skimmed through my form, looking at the inputs and what name I had assigned them, but they were all fine, however the submit buttons were named &#8220;method&#8221; &#8211; which is a DOM property for forms!  The comment quickly made sense and I knew I had found the problem; the submit button was causing a problem when I was trying to get the method property from the form through getAttribute()&#8230; it was clashing with the name property from the submit button because it&#8217;s name was set to &#8220;method&#8221; and this was causing Internet Explorer 7 to crash!</p>
<p>The fix was relatively simple &#8211; I just renamed my submit button to something other than &#8220;method&#8221; and presto, Internet Explorer 7 now worked just fine (and I was able to re-enable my second submit button without any problems too).  Well, I shouldn&#8217;t say <em>fine</em> since I did discover another problem in that Internet Explorer 7 apparently submits the HTML code in between&lt;button&gt;&#8230;&lt;/button&gt; tags instead of the value property defined on the button element, but that was a simple work-around thankfully.</p>
<p>Stupid Internet Explorer <img src='http://www.nerdscene.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerdscene.com/2009/05/05/115/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AJAX problems with blank responseTexts</title>
		<link>http://www.nerdscene.com/2009/04/21/104/</link>
		<comments>http://www.nerdscene.com/2009/04/21/104/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 16:56:50 +0000</pubDate>
		<dc:creator>Eli Sand</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Firebug]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[readyState]]></category>
		<category><![CDATA[responseText]]></category>
		<category><![CDATA[XMLHttpRequest]]></category>

		<guid isPermaLink="false">http://www.nerdscene.com/?p=104</guid>
		<description><![CDATA[In the middle of developing a web application and doing some routine testing just to make sure my AJAX code was working, I stumbled upon a rather odd and what seemed to be rather random error in Firefox 3. It took some debugging and a bit of speculation to figure out what the problem most [...]]]></description>
			<content:encoded><![CDATA[<p>In the middle of developing a web application and doing some routine testing just to make sure my AJAX code was working, I stumbled upon a rather odd and what seemed to be rather random error in Firefox 3.  It took some debugging and a bit of speculation to figure out what the problem most likely was and how I hoped I fixed it.<br />
<span id="more-104"></span><br />
The problem was with a refresh button I had created, which would submit form data via an AJAX POST call and I would take the responseText I got back and replace a DOM node with a replacement DOM node I got from the AJAX call.  Upon initial testing everything seemed to work fine, but once in a while after hitting the refresh button about 10 or so times, the DOM node I was updating would get erased!  It didn&#8217;t seem to happen in Internet Explorer 8, just Firefox 3 (and Firefox 2 as well).</p>
<p>After doing some initial debugging, it seemed that my responseText was coming back blank &#8211; but Firebug clearly showed that Firefox was getting the full DOM document back from the AJAX POST call, so I knew something was up with how the response was being handled by AJAX.  Now, I use jQuery for the majority of my JavaScript code, so I was a bit surprised to find out that there was an AJAX problem since I figured that a bug like this would have likely at least already been reported.  After a lot of searching on Google however, I only turned up one result that was quite similar to my problem which had no resolution.  So it looked like I would have to solve this one entirely on my own.</p>
<p>I did more debugging, and out of pure luck I ended up noticing that the readyState on my XHR object was set to 0, which means that apparently an AJAX call hadn&#8217;t even been made yet.  I found this rather odd to see a readyState of 0 since clearly an AJAX call <em>had</em> been made (and returned with success).  I thought about the situation a bit and figured that perhaps I should move my debugging call (I was using console.log()) up the chain a bit so I did it as the first call from my AJAX completion callback function.  After doing that I noticed that it was now correctly showing a readyState of 4.  This meant that somewhere down the line, something was happening to my XHR object causing the readyState to be reset&#8230; and possibly resetting my entire XHR object!</p>
<p>Sure enough, I was indeed correct!  The problem was that I was trying to directly access my XHR object from within a jQuery animation callback which obviously uses timers.  Now, here is where I speculate because the problem only happens in Firefox, but I&#8217;m guessing that the XHR object was somehow being reset or altered after some time&#8230; very likely an internal browser cache system that was purging my XHR object.  My solution was to simply copy the responseText to a variable before entering in to any timer based jQuery calls (essentially, I assigned the responseText to a variable as the first call from my completion callback function).  Then, from within my jQuery animation callback I simply referred to the variable I created which had a copy of the responseText.  No more random blank responseTexts!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerdscene.com/2009/04/21/104/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

