<?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: The right encoding for your Ajax views</title>
	<atom:link href="http://cakebaker.42dh.com/2006/01/17/the-right-encoding-for-your-ajax-views/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2006/01/17/the-right-encoding-for-your-ajax-views/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Tue, 16 Mar 2010 17:17:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2006/01/17/the-right-encoding-for-your-ajax-views/comment-page-1/#comment-125725</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Thu, 16 Apr 2009 14:35:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=64#comment-125725</guid>
		<description>@Nasir: Thanks for sharing!</description>
		<content:encoded><![CDATA[<p>@Nasir: Thanks for sharing!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nasir Gulzade</title>
		<link>http://cakebaker.42dh.com/2006/01/17/the-right-encoding-for-your-ajax-views/comment-page-1/#comment-125698</link>
		<dc:creator>Nasir Gulzade</dc:creator>
		<pubDate>Thu, 16 Apr 2009 05:14:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=64#comment-125698</guid>
		<description>Dear All, 
Since I was having trouble with AJAX charset encoding today in the morning with refresh mind I found the solution, the reason why I am posting here is , I searched 2 whole days to find a solution from forums, etc but I could not. however now I am lucky to find the solution for any language just using utf-8 first let mi write my ajax  
My Ajax code is like below:
not:you can save below code to a page like ajax_post.js
&lt;code&gt;
var xmlhttp_sp = false;

try {
//If the Javascript version is greater than 5.
      xmlhttp_sp = new ActiveXObject(&quot;Msxml2.XMLHTTP&quot;);

    } catch (e) {
//If not, then use the older active x object.
try {

       xmlhttp_sp = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);

} catch (E) {
//Else we must be using a non-IE browser.
              xmlhttp_sp = false;
            }
}

if (!xmlhttp_sp &amp;&amp; typeof XMLHttpRequest != &#039;undefined&#039;) {
          xmlhttp_sp = new XMLHttpRequest();

}

function makerequest_sp(serverPage, params, objID)
{  
    var myRandom=parseInt(Math.random()*99999999);
    
    params+=&#039;&amp;&#039;+myRandom;

    var url = serverPage;
    //var params = &quot;lorem=ipsum&amp;name=binny&quot;;
    xmlhttp_sp.open(&quot;POST&quot;, url, true);
    //Send the proper header information along with the request
    xmlhttp_sp.setRequestHeader(&quot;Content-type&quot;, &quot;application/x-www-form-urlencoded; charset=UTF-8&quot;);
    xmlhttp_sp.setRequestHeader(&quot;Content-length&quot;, params.length);
    xmlhttp_sp.setRequestHeader(&quot;Connection&quot;, &quot;close&quot;);
    xmlhttp_sp.onreadystatechange = function() {//Call a function when the state changes.
    if(xmlhttp_sp.readyState == 4 &amp;&amp; xmlhttp_sp.status == 200) {
        document.getElementById(objID).innerHTML = xmlhttp_sp.responseText;
        //alert(xmlhttp_sp.responseText);  
    }
    }
    xmlhttp_sp.send(params);    

    //xmlhttp_sp.send(null); 
}
&lt;/code&gt; 
before  I was using AJAX with GET method but when I GET form values in my language (farsi Afghanistan) it was just ???? and after using above ajax code I solved my problem.

//some comments
function makerequest_sp(serverPage, params, objID)

when you wanna call makerequest_sp it takes 3 params
1.serverPage  like test.php
2.params the values of a form like  name=nasir&amp;id=34&amp; ...
3.objID is div id where you want to show xmlhttp_sp.responseText inside a div.

how you call this let me write a function how did I call
&lt;code&gt;
function  test_dari(formid)
{
 var formvalues = do_it(formid);
//this do_it  function will retrieve all form name with its value
  url=&#039;test.php&#039;;
 var params=formvalues+&#039;action=getform&amp;&#039;
  makerequest_sp(url, params, &#039;mytest&#039;); //here is ajax call function
}
&lt;/code&gt;
any help you want please write to me.
naser@netlinks.af</description>
		<content:encoded><![CDATA[<p>Dear All,<br />
Since I was having trouble with AJAX charset encoding today in the morning with refresh mind I found the solution, the reason why I am posting here is , I searched 2 whole days to find a solution from forums, etc but I could not. however now I am lucky to find the solution for any language just using utf-8 first let mi write my ajax<br />
My Ajax code is like below:<br />
not:you can save below code to a page like ajax_post.js<br />
<pre><code>var xmlhttp_sp = false;

try {
//If the Javascript version is greater than 5.
      xmlhttp_sp = new ActiveXObject("Msxml2.XMLHTTP");

    } catch (e) {
//If not, then use the older active x object.
try {

       xmlhttp_sp = new ActiveXObject("Microsoft.XMLHTTP");

} catch (E) {
//Else we must be using a non-IE browser.
              xmlhttp_sp = false;
            }
}

if (!xmlhttp_sp &amp;amp;&amp;amp; typeof XMLHttpRequest != 'undefined') {
          xmlhttp_sp = new XMLHttpRequest();

}

function makerequest_sp(serverPage, params, objID)
{  
    var myRandom=parseInt(Math.random()*99999999);
    
    params+='&amp;amp;'+myRandom;

    var url = serverPage;
    //var params = "lorem=ipsum&amp;amp;name=binny";
    xmlhttp_sp.open("POST", url, true);
    //Send the proper header information along with the request
    xmlhttp_sp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
    xmlhttp_sp.setRequestHeader("Content-length", params.length);
    xmlhttp_sp.setRequestHeader("Connection", "close");
    xmlhttp_sp.onreadystatechange = function() {//Call a function when the state changes.
    if(xmlhttp_sp.readyState == 4 &amp;amp;&amp;amp; xmlhttp_sp.status == 200) {
        document.getElementById(objID).innerHTML = xmlhttp_sp.responseText;
        //alert(xmlhttp_sp.responseText);  
    }
    }
    xmlhttp_sp.send(params);    

    //xmlhttp_sp.send(null); 
}</code></pre><br />
before  I was using AJAX with GET method but when I GET form values in my language (farsi Afghanistan) it was just ???? and after using above ajax code I solved my problem.</p>
<p>//some comments<br />
function makerequest_sp(serverPage, params, objID)</p>
<p>when you wanna call makerequest_sp it takes 3 params<br />
1.serverPage  like test.php<br />
2.params the values of a form like  name=nasir&amp;id=34&amp; &#8230;<br />
3.objID is div id where you want to show xmlhttp_sp.responseText inside a div.</p>
<p>how you call this let me write a function how did I call<br />
<pre><code>function  test_dari(formid)
{
 var formvalues = do_it(formid);
//this do_it  function will retrieve all form name with its value
  url='test.php';
 var params=formvalues+'action=getform&amp;amp;'
  makerequest_sp(url, params, 'mytest'); //here is ajax call function
}</code></pre><br />
any help you want please write to me.<br />
<a href="mailto:naser@netlinks.af">naser@netlinks.af</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2006/01/17/the-right-encoding-for-your-ajax-views/comment-page-1/#comment-42678</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Tue, 11 Dec 2007 16:37:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=64#comment-42678</guid>
		<description>@Tim: Good to hear you could solve your encoding issues!</description>
		<content:encoded><![CDATA[<p>@Tim: Good to hear you could solve your encoding issues!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Daldini</title>
		<link>http://cakebaker.42dh.com/2006/01/17/the-right-encoding-for-your-ajax-views/comment-page-1/#comment-41674</link>
		<dc:creator>Tim Daldini</dc:creator>
		<pubDate>Sun, 09 Dec 2007 04:11:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=64#comment-41674</guid>
		<description>Fiiinally, adding “encoding” =&gt; “utf8″ to the database config basicly solved it.

this was very hard to debug since putting a string containing special characters simply hardcoded in the ajax view failed as well, which made me think it was not a database related issue, but it was because dreamweaver saved the file in western european encoding by default...

It also works in debugmode in IE7 and FF even though the utf8 header is not set by the requesthandler (when debug &gt; 1).

So anyway, thanks!</description>
		<content:encoded><![CDATA[<p>Fiiinally, adding “encoding” =&gt; “utf8″ to the database config basicly solved it.</p>
<p>this was very hard to debug since putting a string containing special characters simply hardcoded in the ajax view failed as well, which made me think it was not a database related issue, but it was because dreamweaver saved the file in western european encoding by default&#8230;</p>
<p>It also works in debugmode in IE7 and FF even though the utf8 header is not set by the requesthandler (when debug &gt; 1).</p>
<p>So anyway, thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Daldini</title>
		<link>http://cakebaker.42dh.com/2006/01/17/the-right-encoding-for-your-ajax-views/comment-page-1/#comment-41658</link>
		<dc:creator>Tim Daldini</dc:creator>
		<pubDate>Sun, 09 Dec 2007 01:47:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=64#comment-41658</guid>
		<description>First of all, I found out the requesthandler component only adds the utf header when debug is lower than 2...even though that still didnt solve my problem. ;)

Furthermore, good question. To be honest, I am in doubt about some stuff regarding UTF-8 and I haven&#039;t really bothered with it that much.

Is it really required that:
- The UTF enconding is specified in a meta tag
- A UTF header is included along with the requested page (php header function)
- The file itself should also be stored in UTF-8 encoding...which is new to me even though it really makes sense. I&#039;m using dreamweaver at this time, and at first glance it seems files are saved in western european encoding.

However, I&#039;m uploading all of my files to a local testserver through FTP and I don&#039;t know how that may affect encoding either, so is there a way to check in what what format the stored file is actually encoded on the testserver via a Linux console...or doesnt that make sense?</description>
		<content:encoded><![CDATA[<p>First of all, I found out the requesthandler component only adds the utf header when debug is lower than 2&#8230;even though that still didnt solve my problem. ;)</p>
<p>Furthermore, good question. To be honest, I am in doubt about some stuff regarding UTF-8 and I haven&#8217;t really bothered with it that much.</p>
<p>Is it really required that:<br />
- The UTF enconding is specified in a meta tag<br />
- A UTF header is included along with the requested page (php header function)<br />
- The file itself should also be stored in UTF-8 encoding&#8230;which is new to me even though it really makes sense. I&#8217;m using dreamweaver at this time, and at first glance it seems files are saved in western european encoding.</p>
<p>However, I&#8217;m uploading all of my files to a local testserver through FTP and I don&#8217;t know how that may affect encoding either, so is there a way to check in what what format the stored file is actually encoded on the testserver via a Linux console&#8230;or doesnt that make sense?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2006/01/17/the-right-encoding-for-your-ajax-views/comment-page-1/#comment-40698</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Thu, 06 Dec 2007 17:48:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=64#comment-40698</guid>
		<description>@Tim: Hm, do you store your files with UTF-8 encoding?</description>
		<content:encoded><![CDATA[<p>@Tim: Hm, do you store your files with UTF-8 encoding?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Daldini</title>
		<link>http://cakebaker.42dh.com/2006/01/17/the-right-encoding-for-your-ajax-views/comment-page-1/#comment-40309</link>
		<dc:creator>Tim Daldini</dc:creator>
		<pubDate>Wed, 05 Dec 2007 20:21:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=64#comment-40309</guid>
		<description>I&#039;m having the same problem with the ajax autocompleter.

I found this in the renderAs method from the requesthandlercomponent:
return $this-&gt;respondAs(&#039;html&#039;, array(&#039;charset&#039; =&gt; &#039;UTF-8&#039;));

seems like nowadays cake adds the utf header if you add the component in your controller. However, I did some testing, involving returning a list with a single item containing a foreign character (which i just hardcoded in the ajax list view, i did not fetch anything from the database) and the problem still is occuring in both IE and Firefox. Any ideas?</description>
		<content:encoded><![CDATA[<p>I&#8217;m having the same problem with the ajax autocompleter.</p>
<p>I found this in the renderAs method from the requesthandlercomponent:<br />
return $this-&gt;respondAs(&#8216;html&#8217;, array(&#8216;charset&#8217; =&gt; &#8216;UTF-8&#8242;));</p>
<p>seems like nowadays cake adds the utf header if you add the component in your controller. However, I did some testing, involving returning a list with a single item containing a foreign character (which i just hardcoded in the ajax list view, i did not fetch anything from the database) and the problem still is occuring in both IE and Firefox. Any ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2006/01/17/the-right-encoding-for-your-ajax-views/comment-page-1/#comment-7186</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Tue, 19 Jun 2007 06:54:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=64#comment-7186</guid>
		<description>@Rainer: I am glad to hear that, thanks :)</description>
		<content:encoded><![CDATA[<p>@Rainer: I am glad to hear that, thanks :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rainer</title>
		<link>http://cakebaker.42dh.com/2006/01/17/the-right-encoding-for-your-ajax-views/comment-page-1/#comment-7094</link>
		<dc:creator>Rainer</dc:creator>
		<pubDate>Sun, 17 Jun 2007 09:01:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=64#comment-7094</guid>
		<description>That was the error!!

Thank you, for your nice great work!

I really appreciate this!!

Greetings, Rainer</description>
		<content:encoded><![CDATA[<p>That was the error!!</p>
<p>Thank you, for your nice great work!</p>
<p>I really appreciate this!!</p>
<p>Greetings, Rainer</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rainer</title>
		<link>http://cakebaker.42dh.com/2006/01/17/the-right-encoding-for-your-ajax-views/comment-page-1/#comment-7093</link>
		<dc:creator>Rainer</dc:creator>
		<pubDate>Sun, 17 Jun 2007 08:53:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=64#comment-7093</guid>
		<description>That was the error... Thank you, for your work!!

i really appreciate this!!

Greetings, Rainer</description>
		<content:encoded><![CDATA[<p>That was the error&#8230; Thank you, for your work!!</p>
<p>i really appreciate this!!</p>
<p>Greetings, Rainer</p>
]]></content:encoded>
	</item>
</channel>
</rss>
