<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: passing parameters to XMLHttpRequest&#8217;s onreadystatechange function</title>
	<atom:link href="http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/feed/" rel="self" type="application/rss+xml" />
	<link>http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/</link>
	<description>thoughts on open spaces</description>
	<lastBuildDate>Thu, 10 May 2012 04:20:06 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
	<item>
		<title>By: Peter</title>
		<link>http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/comment-page-1/#comment-107510</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Thu, 10 May 2012 04:20:06 +0000</pubDate>
		<guid isPermaLink="false">http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/#comment-107510</guid>
		<description>&lt;p&gt;Thank you thank you thank you thank you thank you thank you thank you!!!!!!!!!!!!!!!!!!!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thank you thank you thank you thank you thank you thank you thank you!!!!!!!!!!!!!!!!!!!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Viju</title>
		<link>http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/comment-page-1/#comment-105245</link>
		<dc:creator>Viju</dc:creator>
		<pubDate>Thu, 17 Nov 2011 07:02:38 +0000</pubDate>
		<guid isPermaLink="false">http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/#comment-105245</guid>
		<description>&lt;p&gt;Cool trick! Thanks a tun.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Cool trick! Thanks a tun.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Alice</title>
		<link>http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/comment-page-1/#comment-100957</link>
		<dc:creator>Alice</dc:creator>
		<pubDate>Thu, 25 Feb 2010 23:45:10 +0000</pubDate>
		<guid isPermaLink="false">http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/#comment-100957</guid>
		<description>&lt;p&gt;instead of this.foo you could have used &#039;test&#039; directly!!! you are passing a value to someone who already has the value with him :)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>instead of this.foo you could have used &#8216;test&#8217; directly!!! you are passing a value to someone who already has the value with him <img src='http://whacked.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>]]></content:encoded>
	</item>
	<item>
		<title>By: Chetna</title>
		<link>http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/comment-page-1/#comment-100956</link>
		<dc:creator>Chetna</dc:creator>
		<pubDate>Thu, 25 Feb 2010 23:41:08 +0000</pubDate>
		<guid isPermaLink="false">http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/#comment-100956</guid>
		<description>&lt;p&gt;i don&#039;t think req.foo or this.foo , either is required. I used foo directly and it worked for me. I didn&#039;t even have to pass any parameter.The point here is : You are introducing an inner function which is in the scope of the outer function.Hence, all the variables can be directly referenced.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>i don&#8217;t think req.foo or this.foo , either is required. I used foo directly and it worked for me. I didn&#8217;t even have to pass any parameter.The point here is : You are introducing an inner function which is in the scope of the outer function.Hence, all the variables can be directly referenced.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: pirhotek</title>
		<link>http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/comment-page-1/#comment-99803</link>
		<dc:creator>pirhotek</dc:creator>
		<pubDate>Mon, 07 Sep 2009 00:24:22 +0000</pubDate>
		<guid isPermaLink="false">http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/#comment-99803</guid>
		<description>&lt;p&gt;you could have simply referenced req.foo, rather than this.foo, as req is still in scope inside the inner function.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>you could have simply referenced req.foo, rather than this.foo, as req is still in scope inside the inner function.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Kosta</title>
		<link>http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/comment-page-1/#comment-98227</link>
		<dc:creator>Kosta</dc:creator>
		<pubDate>Fri, 28 Nov 2008 17:42:37 +0000</pubDate>
		<guid isPermaLink="false">http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/#comment-98227</guid>
		<description>&lt;p&gt;Thank you very much for this hack. Let me avoid ugly global variables.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thank you very much for this hack. Let me avoid ugly global variables.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Krishna</title>
		<link>http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/comment-page-1/#comment-97954</link>
		<dc:creator>Krishna</dc:creator>
		<pubDate>Mon, 22 Sep 2008 15:26:43 +0000</pubDate>
		<guid isPermaLink="false">http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/#comment-97954</guid>
		<description>&lt;p&gt;var req = initRequest(url);
req.onreadystatechange = function()
  {
    if (req.readyState != 4) 
 return;
 if (req.status == 200 ) {
                                //alert(flagforsubmit);
                flagforsubmit = true;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;            loadXML(req.responseXML);                   
           }    

   };      
   req.open(&quot;GET&quot;, url, true);       req.send(null);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;if(flagforsubmit){
///code is not executed 
}
since the flagforsubmit is not true its is taking too much time for execute and when i click the button on which i have called the function is not working(no action) after pressing 3 /4 times  the output will come,&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>var req = initRequest(url);
req.onreadystatechange = function()
  {
    if (req.readyState != 4) 
 return;
 if (req.status == 200 ) {
                                //alert(flagforsubmit);
                flagforsubmit = true;</p>

<pre><code>            loadXML(req.responseXML);                   
           }    

   };      
   req.open("GET", url, true);       req.send(null);
</code></pre>

<p>if(flagforsubmit){
///code is not executed 
}
since the flagforsubmit is not true its is taking too much time for execute and when i click the button on which i have called the function is not working(no action) after pressing 3 /4 times  the output will come,</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Will</title>
		<link>http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/comment-page-1/#comment-97946</link>
		<dc:creator>Will</dc:creator>
		<pubDate>Sun, 14 Sep 2008 04:11:28 +0000</pubDate>
		<guid isPermaLink="false">http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/#comment-97946</guid>
		<description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;I tried this method - no joy.&lt;/p&gt;

&lt;p&gt;Any ideas where I&#039;m messing up? Thanks.&lt;/p&gt;

&lt;p&gt;I&#039;m trying to pass the variable &#039;url&#039; down to the next function.&lt;/p&gt;

&lt;p&gt;function getData(url)
{ 
    var data&lt;em&gt;to&lt;/em&gt;send=&quot;graph&lt;em&gt;request=graph&lt;/em&gt;counter1&quot;;
    var req = new XMLHttpRequest();
    req.open(&quot;POST&quot;, url, true); 
    req.onreadystatechange = function(url)
    {
    return function() {
        document.getElementById(&quot;zone1&quot;).innerHTML = &quot;0&quot;;
        if(req.readyState == 4 &amp;&amp; req.status == 200)
        {
            document.getElementById(&quot;zone1&quot;).innerHTML  = req.responseText;&lt;br /&gt;
            setTimeout(&quot;getData(url)&quot;, 3000); //refresh rate for graph (ms)
        } 
    }(url);
    };&lt;br /&gt;
    req.setRequestHeader(&quot;Content-Type&quot;, &quot;application/x-www-form-urlencoded&quot;);
    req.send(data&lt;em&gt;to&lt;/em&gt;send); 
} &lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi,</p>

<p>I tried this method &#8211; no joy.</p>

<p>Any ideas where I&#8217;m messing up? Thanks.</p>

<p>I&#8217;m trying to pass the variable &#8216;url&#8217; down to the next function.</p>

<p>function getData(url)
{ 
    var data<em>to</em>send=&#8221;graph<em>request=graph</em>counter1&#8243;;
    var req = new XMLHttpRequest();
    req.open(&#8220;POST&#8221;, url, true); 
    req.onreadystatechange = function(url)
    {
    return function() {
        document.getElementById(&#8220;zone1&#8243;).innerHTML = &#8220;0&#8243;;
        if(req.readyState == 4 &amp;&amp; req.status == 200)
        {
            document.getElementById(&#8220;zone1&#8243;).innerHTML  = req.responseText;<br />
            setTimeout(&#8220;getData(url)&#8221;, 3000); //refresh rate for graph (ms)
        } 
    }(url);
    };<br />
    req.setRequestHeader(&#8220;Content-Type&#8221;, &#8220;application/x-www-form-urlencoded&#8221;);
    req.send(data<em>to</em>send); 
} </p>]]></content:encoded>
	</item>
	<item>
		<title>By: Scott F</title>
		<link>http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/comment-page-1/#comment-97916</link>
		<dc:creator>Scott F</dc:creator>
		<pubDate>Wed, 27 Aug 2008 07:32:01 +0000</pubDate>
		<guid isPermaLink="false">http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/#comment-97916</guid>
		<description>&lt;p&gt;Thanks a lot for your help. I was having the same scope problems.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks a lot for your help. I was having the same scope problems.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Todd dellagio</title>
		<link>http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/comment-page-1/#comment-89163</link>
		<dc:creator>Todd dellagio</dc:creator>
		<pubDate>Mon, 31 Mar 2008 20:22:16 +0000</pubDate>
		<guid isPermaLink="false">http://whacked.net/2007/11/27/passing-parameters-to-xmlhttprequests-onreadystatechange-function/#comment-89163</guid>
		<description>&lt;p&gt;Hey thanks for this post. I was having a very similar issue and that got resolved. Thanks lau.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hey thanks for this post. I was having a very similar issue and that got resolved. Thanks lau.</p>]]></content:encoded>
	</item>
</channel>
</rss>

