<?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>Office-it.orG &#187; Ajax</title>
	<atom:link href="http://www.office-it.org/category/web-application/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.office-it.org</link>
	<description>All about Web and Desktop Application</description>
	<lastBuildDate>Tue, 20 Jul 2010 23:38:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>innerHTML and Ajax – Bad Combination</title>
		<link>http://www.office-it.org/innerhtml-and-ajax-%e2%80%93-bad-combination/</link>
		<comments>http://www.office-it.org/innerhtml-and-ajax-%e2%80%93-bad-combination/#comments</comments>
		<pubDate>Mon, 07 Jan 2008 08:54:14 +0000</pubDate>
		<dc:creator>Hii Hiong Ching</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[innerHTML]]></category>

		<guid isPermaLink="false">http://office-it.org/?p=22</guid>
		<description><![CDATA[Ajax is comparatively new to the world of programming and software. So far, only few people have cracked the use of this program without the use of toolkits. Only God knows how many people who can actually code without using toolkits but I’m willing to bet that they don’t really reach that much. Saying that [...]]]></description>
			<content:encoded><![CDATA[<p>Ajax is comparatively new to the world of programming and software. So far, only few people have cracked the use of this program without the use of toolkits. Only God knows how many people who can actually code without using toolkits but I’m willing to bet that they don’t really reach that much. Saying that only a rocket scientist could figure out how to properly code Ajax is probably an understatement considering its requirements from a developer.</p>
<p>But if you have figured Ajax out, good for you. On my end, I was able to do a little bit of Ajax project from time to time but I still have troubles figuring things out. It’s still a matter of trial and error for me.</p>
<p>In my journey in figuring out Ajax, I came into contact with one of the peculiar situation that will only happen to Ajax. If you have been to the world of programming language, you may already have encountered innerHTML. This little tool is often used by programmers to easy write objects in a DIV. Although the longer way of using DOM is also good, programmers naturally select the easier way… including me.</p>
<p><span id="more-22"></span>But things got awry when I tried to use innerHTML while I was building an Ajax based software. You may already have heard how Ajax can be as complicated as it combines different programming languages into one complicated program. The end result will always be a beauty but it will take your time and effort just to make one simple program. By all means, I have to look for way to make my Ajax coding a little bit easier. Instead of using DOM for myDiv, I decided to use innerHTML. Although Ajax still took time to be finished, using innerHTML helped me get through the challenges in creating this complicated program.</p>
<p>Thinking that I already have a pretty good Ajax software I decided to make it run. But as soon as it started, I figured out something is definitely wrong with my program. The information I entered doesn’t seemed to be processing as planned. Worst memory leaks seemed to be plaguing the program, causing me to re-evaluate the entire program right from the scratch. Soon enough, I traced the problem in innerHTML. Apparently innerHTML cannot process the XML documents that well causing it to bypass, or even withheld some information. Although memory leaks doesn’t happen in Mozilla, more than 80% of the worldwide users are into IE and this is where the problem usually starts. The only resort for this Ajax based program to work is to change the innerHTML into DOM. I know it’s going to be really complicated but considering the consequences, you should stick to the longer but safer road of DOM. Ajax is not only for rocket scientists but also patient rocket scientists.</p>
<p>So if you want a stronger Ajax-based software that could practically be stable in IE; ignore innerHTML as much as you can and use DOM. Although it will take some time, you may never have to review your program again.</p>
<img src="http://www.office-it.org/?ak_action=api_record_view&id=22&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.office-it.org/innerhtml-and-ajax-%e2%80%93-bad-combination/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why innerHTML can ruin your AJAX applications</title>
		<link>http://www.office-it.org/why-innerhtml-can-ruin-your-ajax-applications/</link>
		<comments>http://www.office-it.org/why-innerhtml-can-ruin-your-ajax-applications/#comments</comments>
		<pubDate>Mon, 07 Jan 2008 08:44:47 +0000</pubDate>
		<dc:creator>Hii Hiong Ching</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[innerHTML]]></category>

		<guid isPermaLink="false">http://office-it.org/?p=21</guid>
		<description><![CDATA[The reason I am writing this article is because of some work I have been doing recently. My client wants a persistent AJAX application to work in IE6+. This means the web page will be left running for days/weeks on end without being refreshed or the browser being closed. This means it cannot have ANY [...]]]></description>
			<content:encoded><![CDATA[<p>The reason I am writing this article is because of some work I have been doing recently. My client wants a persistent AJAX application to work in IE6+. This means the web page will be left running for days/weeks on end without being refreshed or the browser being closed. This means it cannot have ANY memory leaks.</p>
<p>I currently process incoming XML using an XSL document &#8211; which works very well. However when done under IE6 the XSL transformation is output as plain text [please let me know if there is a DOM alternative] which means the only way to insert my newly transformed code is to use innerHTML. This seems to leak memory like a biatch! Note that the leak doesn&#8217;t occur in FireFox.</p>
<p>So why does innerHTML leak? Well after some digging I found out a few interesting facts &#8211; lets look at the who, where, why and how&#8230;</p>
<p><span id="more-21"></span><strong>Where did innerHTML come from?</strong><br />
innerHTML is not a standard, it is a proprietary format by Microsoft. Given Microsoft&#8217;s huge installed base and popularity other browsers included innerHTML for the sake of compatibility. It was never in the w3c specification. It subsequently isn&#8217;t future proof and isn&#8217;t designed for xhtml [xml mime type].</p>
<p><strong>Why is innerHTML used?</strong><br />
innerHTML is used as a cheap and easy way to write objects to a container element like a span or DIV. It tends to be faster than traditional DOM methods and takes substantially less time to write. For example you can quickly write a table structure into a DIV container using innerHTML like so:</p>
<pre lang="html">
var myDiv = document.getElementById('myDivId');
myDiv.innerHTML = "
<table>
<tr>
<th>Title</th>
</tr>
<tr>
<td>Mr</td>
</tr>
</table>

";
</pre>
<p>The equivalent code using DOM methods would take up considerably more time and lines of code to accomplish. So for lazy coders or new guys innerHTML provides a great way into the world of JavaScript. To be fair to innerHTML, it works very well for the most part, yes its ugly, its not &#8220;right&#8221; but if your in a rush and don&#8217;t have the requirements my client has then it can work very well. You should try, where possible, to avoid it though as it can have unpredictable results and its a bad habit to rely on innerHTML to change or update your web page. DOM methods, in the long run, will serve you better.</p>
<p><strong>So why / how does innerHTML leak memory?</strong><br />
The specific answer to this I do not know but we can theorize a solution. Firstly, as previously discussed, innerHTML is not designed to work with xhtml documents, meaning that it can incorrectly interpret the string you pass to it. This means it doesn&#8217;t actually render exactly what you ask it to &#8211; basically it adds things you never asked for. If you parse the html later on using DOM methods you may run into errors or bugs where the DOM hierarchy isn&#8217;t as you expected.</p>
<p><strong>Is there a solution?</strong><br />
Yes! Simply don&#8217;t use innerHTML. I don&#8217;t think you&#8217;ll ever find an article, and there are quite a few, that puts in in good light [aside from its obvious benefits]. However if you are in my position and are forced to use it then, apparently, there are a few things you can try doing.</p>
<p>Firstly as the memory leak may be coming from its incompatibility with xhtml it is well worth re-writing your code to accommodate this, or by re-structuring your xhtml in a different way. Unfortunately it&#8217;s quite hard to know exactly what innerHTML is doing so its a bit of guess work.</p>
<p>If you wish to use DOM methods to replace your existing innerHTML code then please look at this very good article on <a href="http://slayeroffice.com/articles/innerHTML_alternatives/">innerHTML alternatives</a>.</p>
<img src="http://www.office-it.org/?ak_action=api_record_view&id=21&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.office-it.org/why-innerhtml-can-ruin-your-ajax-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cool Effects from Prototype and Scriptaculous</title>
		<link>http://www.office-it.org/cool-effects-from-prototype-and-scriptaculous/</link>
		<comments>http://www.office-it.org/cool-effects-from-prototype-and-scriptaculous/#comments</comments>
		<pubDate>Sun, 06 Jan 2008 08:29:22 +0000</pubDate>
		<dc:creator>Hii Hiong Ching</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[collection]]></category>
		<category><![CDATA[Effects]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[Scriptaculous]]></category>

		<guid isPermaLink="false">http://office-it.org/?p=18</guid>
		<description><![CDATA[Script.aculo.us is a cool library for effects. I collect samples from different places in this page. Enjoy it! Extra Tip: protoculous is a javascript file which contains Prototype and Scriptaculous together compressed. Cool effects: Accordion effect Auto-scrolling page navigation Carousel (able to use with Rails) Crossfader Data Picker FrogJS Javascript Gallery Goofy Boxes Image Transition [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Script.aculo.us</strong> is a cool library for <strong>effects</strong>. I collect samples from different places in this page. Enjoy it!<br />
<strong>Extra Tip:</strong> <a href="http://protoculous.wikeo.be/">protoculous</a> is a javascript file which contains <code>Prototype</code> and <code>Scriptaculous</code> together compressed.</p>
<h3>Cool effects:</h3>
<ol>
<li><a href="http://www.stickmanlabs.com/accordion/" target="_blank">Accordion effect</a></li>
<li><a href="http://tobielangel.com/examples/auto-scrolling-page-navigation" target="_blank">Auto-scrolling page navigation </a></li>
<li><a href="http://prototype-carousel.xilinus.com/" target="_blank">Carousel (able to use with Rails)</a></li>
<li><a href="http://mikeomatic.net/techtips/css-crossfader/" target="_blank">Crossfader</a></li>
<li><a href="http://www.eulerian.com/en/opensource/datepicker-prototype-scriptaculous" target="_blank">Data Picker </a></li>
<li><a href="http://www.puidokas.com/portfolio/frogjs/" target="_blank">FrogJS Javascript Gallery</a></li>
<li><a href="http://ajaxorized.com/goofyboxes/" target="_blank">Goofy Boxes </a></li>
<li><a href="http://ajaxorized.com/projects/image-transition-manager-image-transitions-with-scriptaculous/" target="_blank">Image Transition Manager</a></li>
<li><a href="http://www.huddletogether.com/projects/lightbox2/" target="_blank">Lightbox</a></li>
<li><a href="http://www.stickmanlabs.com/lightwindow/" target="_blank">Lightwindow: Lightbox prototype.js version</a></li>
<li><a href="http://www.wildbit.com/demos/modalbox/" target="_blank">Modalbox: like Mac OS </a></li>
<li><a href="http://ajaxorized.com/?p=14" target="_blank">Password strength meter</a></li>
<li><a href="http://prototype-window.xilinus.com/" target="_blank">Prototype window </a></li>
<li><a href="http://scal.fieldguidetoprogrammers.com/" target="_blank">Scal: calendar component</a></li>
<li><a href="http://pragmaticobjects.org/index.php?itemid=7" target="_blank">Slideshow</a></li>
<li><a href="http://lifedraft.de/projekte/dhonishow/" target="_blank">Slideshow 2</a></li>
<li><a href="http://www.aldenta.com/examples/script.aculo.us/" target="_blank">Scroll with slide component</a></li>
<li><a href="http://www.stickmanlabs.com/scroller/scrollbar/" target="_blank">Scroll 2</a></li>
<li><a href="http://www.ajaxlessons.com/2006/02/19/ajax-workshop-3-shopping-cart-using-scriptaculous" target="_blank">Shopping cart</a></li>
<li><a href="http://blog.innerewut.de/2006/10/19/a-prototype-based-javascript-tooltip" target="_blank">Tooltips</a></li>
<li><a href="http://tetlaw.id.au/view/javascript/really-easy-field-validation" target="_blank">Validation</a></li>
</ol>
<img src="http://www.office-it.org/?ak_action=api_record_view&id=18&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.office-it.org/cool-effects-from-prototype-and-scriptaculous/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Error: uncaught exception: Permission denied to call method XMLHttpRequest.open</title>
		<link>http://www.office-it.org/error-uncaught-exception-permission-denied-to-call-method-xmlhttprequestopen/</link>
		<comments>http://www.office-it.org/error-uncaught-exception-permission-denied-to-call-method-xmlhttprequestopen/#comments</comments>
		<pubDate>Mon, 31 Dec 2007 17:55:45 +0000</pubDate>
		<dc:creator>Hii Hiong Ching</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Permission]]></category>
		<category><![CDATA[XMLHttpRequest]]></category>

		<guid isPermaLink="false">http://office-it.org/?p=4</guid>
		<description><![CDATA[Thanks very much for the following articles as it solve my pain about ajax. If you want to do cross-domain scripting with XMLHttpRequest, e.g. fetching data from a remote location but you&#8217;re on a local page or local XUL application (file:///), you need to tell Mozilla/Firefox about that, otherwise you get the infamous error: Error: [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks very much for the following articles as it solve my pain about ajax.</p>
<p>If you want to do cross-domain scripting with XMLHttpRequest, e.g. fetching data from a remote location but you&#8217;re on a local page or local XUL application (file:///), you need to tell Mozilla/Firefox about that, otherwise you get the infamous error:</p>
<pre lang="php">Error: uncaught exception: Permission denied to call method XMLHttpRequest.open</pre>
<p>Below is an example that can be run locally (save it to your harddisk and open the page with Mozilla/Firefox). It will fetch some RSS XML data from wunderground.com and alert it.</p>
<p><strong>Always remember: XMLHttpRequest needs UniversalBrowserRead!</strong></p>
<p><strong>If the page with the XMLHttpRequest is on a http:// URI (on a webserver), it is not possible to fetch data from another domain!!! This is a security measure of Mozilla/Firefox.</strong></p>
<p><span id="more-4"></span>Still, it comes in handy, if you can read remote data from a local application. E.g. you&#8217;ve got a local XUL application that needs to get data from other servers &#8211; Dude! Sweet! <img src='http://www.office-it.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>If you&#8217;re doing some extension to the Mozilla/Firefox browser, you don&#8217;t need to care about permissions. Such an extension is installed into the core of the browser anyway, hence it has all privileges.</p>
<p><strong>cross-domain-xmlhttprequest.html</strong></p>
<pre lang="php">
<script type="text/javascript" language="javascript">

// Error: uncaught exception: Permission denied to call method XMLHttpRequest.open

  var http_request = false;

  function makeRequest(url, parameters) {

   try {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
   } catch (e) {
    alert("Permission UniversalBrowserRead denied.");
   }

    http_request = false;
    http_request = new XMLHttpRequest();
    if (http_request.overrideMimeType) {
      http_request.overrideMimeType(\\\\\'text/xml\\\\\');
    }
    if (!http_request) {
      alert(\\\\\'Cannot create XMLHTTP instance\\\\\');
      return false;
    }
    http_request.onreadystatechange = alertContents;
    http_request.open(\\\\\'GET\\\\\', url + parameters, true);
    http_request.send(null);
  }

  function alertContents() {
    if (http_request.readyState == 4) {
      if (http_request.status == 200) {

        var string = http_request.responseText;
      alert(string);

      } else {
        alert(\\\\\'There was a problem with the request.\\\\\');
      }
    }
  }
  function updateweather() {
    makeRequest(\\\\\'http://www.wunderground.com/auto/rss_full/global/stations/16239.xml\\\\\', \\\\\'\\\\\');
  }
</script>
<input name="button" value="GET XML" type="button" />
  onclick="javascript:updateweather();"/&gt;</pre>
<img src="http://www.office-it.org/?ak_action=api_record_view&id=4&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.office-it.org/error-uncaught-exception-permission-denied-to-call-method-xmlhttprequestopen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

