<?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>TheGarage Tech Blog &#187; firefox</title>
	<atom:link href="http://garagetechblog.com/tag/firefox/feed/" rel="self" type="application/rss+xml" />
	<link>http://garagetechblog.com</link>
	<description>Tech projects from the corner of a suburban garage</description>
	<lastBuildDate>Sat, 04 Sep 2010 13:07:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>WordPress custom templates and Javascript</title>
		<link>http://garagetechblog.com/2009/09/27/wordpress-custom-templates-and-javascript/</link>
		<comments>http://garagetechblog.com/2009/09/27/wordpress-custom-templates-and-javascript/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 13:55:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Wordpress/Mu]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://garagetechblog.com/?p=660</guid>
		<description><![CDATA[Now that I have solved the recent unauthenticated Ajax problem in my Private Geocache Manager plugin, it&#8217;s time to move on to the second big problem that has plagued me for a while. I wasn&#8217;t even aware of it until I tried to demo the system to a user who worked at a place where [...]]]></description>
			<content:encoded><![CDATA[<p>Now that I have solved the recent <a href="http://garagetechblog.com/2009/09/20/wordpress-ajax-and-wpdb/">unauthenticated Ajax problem</a> in my <a href="http://gulfcoastgeocache.com/">Private Geocache Manager plugin</a>, it&#8217;s time to move on to the second big problem that has plagued me for a while. I wasn&#8217;t even aware of it until I tried to demo the system to a user who worked at a place where Firefox isn&#8217;t available. I developed the plugin entirely in Firefox using only what I thought to be cross-platform utilities. The only thing that would even be close to non-standard code in the entire script library is jsfade, which itself is not complicated and which clearly takes into consideration the Internet Explorer quirks when performing the fade effect.  </p>
<p>Nonetheless I still have a couple of Javascript issues outstanding which pretty much kill the whole deal since the <a href="http://code.google.com/apis/maps/">Google Maps API</a> is entirely a client side, Javascript environment and a big majority of folks still use Internet Explorer.   </p>
<p>The first issue is the getElementById method somehow can&#8217;t figure out that the map canvas div element is in the DOM tree when it clearly is, throwing an &#8216;object expected&#8217; error. I am accessing the elements from ajax calls so the entire page has loaded at the time of the calls so the div has obviously been declared by the time it is accessed. I think what I have to do here is check to see if the element is in the DOM tree before trying to access it. Firefox is smart enough to figure it out but I guess IE needs more explicit directions.</p>
<p>The second issue is that my ajax call is throwing the dreaded &#8216;unspecified error&#8217;. Debugging shows the error occurs at the mySACK.runAJAX() line. It is a simple ajax call using a standard implementation of the <a href="http://www.fecj.org/extra/AJAX-Demythified-for-PHP-programmers.html">Simplified Ajax Code Kit</a>, or SACK, and the code works perfectly in Firefox. </p>
<pre>
    function readMapData(arg) {
      mysack = new sack(ajaxurl); //wordpress admin url for ajax hook
      mysack.setVar('action', 'getVectorMarkers');
      mysack.execute = 0;
      mysack.method = 'POST';
      mysack.setVar('id', arg);
      mysack.onCompletion  = loadOverlay;
      mysack.onError = function() { alert('Ajax error ... '); };
      mysack.runAJAX();
      return true;
    }
</pre>
<p>The onCompletion callback never fires nor does the onError callback. Since I know there is not an error on the server side the next place I need to debug is inside the SACK &#8216;onCompletion&#8217; code, which I&#8217;m not too crazy about. This is where you go, hmmm, maybe I should have just used jQuery for my Ajax in the first place.</p>
<p>So instead of editing a bunch of code that isn&#8217;t mine (the SACK wrapper class) I downloaded and installed the MS Script Editor and used it to find the exact bit of code throwing the error:</p>
<pre>
  if (this.method == "GET") {
     var totalurlstring = this.requestFile + "?" + this.URLString;
     this.xmlhttp.open(this.method, totalurlstring, true);
  }else{
      this.xmlhttp.open(this.method, this.requestFile, true);
  }
</pre>
<p>I&#8217;m using POST method so it&#8217;s the last line throwing the error. This.request is set to the parameter passed when creating the new sack object, in our case the wp_admin url, so the code would translate into </p>
<pre>
xmlhttp.open('POST', 'http://.../wp-admin/admin-ajax.php', true);
</pre>
<p>And that&#8217;s the benefit of writing these posts. Many times you figure out the problem by the time you finish describing it. When  I went to copy the ajaxurl from the editor I noticed a typo in the URL which Firefox can obviously parse but IE can&#8217;t&#8211;I had the first pair of slashes escaped, eg http:///gulfcoastgeocache.com&#8230;.</p>
<p>Grr&#8230;.</p>
<p>So that still leaves me with the aggravating problem of getElementById not working properly. I&#8217;m debugging that now. Once I get that one sorted out I will be 90% complete with the plugin leaving only the initial setup script and the options page to finish. </p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://garagetechblog.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://garagetechblog.com/2009/09/27/wordpress-custom-templates-and-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
