<?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>mdpai.com - Blogging + Tutorial PHP, MySQL, Ajax, Photoshop, Javascript &#187; http response code 0</title>
	<atom:link href="http://www.mdpai.com/tag/http-response-code-0/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mdpai.com</link>
	<description>tutorial php bahasa melayu, mysql, ajax, photoshop, javascript, html, css - mdpai.com</description>
	<lastBuildDate>Mon, 25 Jan 2010 22:23:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ajax response code 0?</title>
		<link>http://www.mdpai.com/tutorial-javascript/ajax-response-code-0/</link>
		<comments>http://www.mdpai.com/tutorial-javascript/ajax-response-code-0/#comments</comments>
		<pubDate>Sat, 23 Feb 2008 04:03:15 +0000</pubDate>
		<dc:creator>mdpai</dc:creator>
				<category><![CDATA[Tutorial Javascript]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[http response code 0]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[xmlhttp.status 0]]></category>

		<guid isPermaLink="false">http://www.mdpai.com/tutorial-javascript/ajax-response-code-0/</guid>
		<description><![CDATA[Masalah berkenaan dengan ajax response code&#8230;


?View Code PHP&#160;
var xmlhttp;
&#160;
if&#40;window.ActiveXObject&#41;&#123;
xmlhttp = new ActiveXObject&#40;&#34;Microsoft.XMLHTTP&#34;&#41;;
&#125;
else &#123;
xmlhttp = new XMLHttpRequest&#40;&#41;;
&#125;
&#160;
function makerequest&#40;serverPage, objID&#41;&#123;
var obj = document.getElementById&#40;objID&#41;;
var url = serverPage+&#34;?weight=&#34;+document.getElementById&#40;'weight'&#41;.value;
xmlhttp.open&#40;&#34;GET&#34;, url&#41;;
xmlhttp.onreadystatechange = function&#40;&#41;&#123;
if&#40;xmlhttp.readyState == 4&#41;&#123;
if&#40;xmlhttp.status == 200&#41;&#123;
obj.value = xmlhttp.responseText;
&#125;
&#125;
&#125;
&#160;
xmlhttp.send&#40;null&#41;;
&#125;

Code di atas kelihatan normal bukan? tapi hari ni saya mendapati ada satu perkara pelik terjadi jika file yang anda cuba akses itu [...]]]></description>
			<content:encoded><![CDATA[<p>Masalah berkenaan dengan ajax response code&#8230;</p>
<p><span id="more-223"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p223code3'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2233"><td class="code" id="p223code3"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> xmlhttp<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>window<span style="color: #339933;">.</span>ActiveXObject<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
xmlhttp <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Microsoft.XMLHTTP&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
xmlhttp <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> makerequest<span style="color: #009900;">&#40;</span>serverPage<span style="color: #339933;">,</span> objID<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">var</span> obj <span style="color: #339933;">=</span> document<span style="color: #339933;">.</span>getElementById<span style="color: #009900;">&#40;</span>objID<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">var</span> url <span style="color: #339933;">=</span> serverPage<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;?weight=&quot;</span><span style="color: #339933;">+</span>document<span style="color: #339933;">.</span>getElementById<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'weight'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>value<span style="color: #339933;">;</span>
xmlhttp<span style="color: #339933;">.</span>open<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;GET&quot;</span><span style="color: #339933;">,</span> url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
xmlhttp<span style="color: #339933;">.</span>onreadystatechange <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>xmlhttp<span style="color: #339933;">.</span>readyState <span style="color: #339933;">==</span> 4<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>xmlhttp<span style="color: #339933;">.</span>status <span style="color: #339933;">==</span> 200<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
obj<span style="color: #339933;">.</span>value <span style="color: #339933;">=</span> xmlhttp<span style="color: #339933;">.</span>responseText<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
xmlhttp<span style="color: #339933;">.</span>send<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Code di atas kelihatan normal bukan? tapi hari ni saya mendapati ada satu perkara pelik terjadi jika file yang anda cuba akses itu merupakan local files dan bukan file yang terdapat di dalam server.  HTTP response code yang akan dikembalikan jika anda akses local file bukannya 200 tetapi 0 ! Jadi berhati2 jika anda cuba untuk mengakses local file, mungkin perkara2 sebegini terjadi.</p>
<p>Untuk menyelesaikan masalah ini,</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p223code4'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2234"><td class="code" id="p223code4"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> xmlhttp<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>window<span style="color: #339933;">.</span>ActiveXObject<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
xmlhttp <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Microsoft.XMLHTTP&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
xmlhttp <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> makerequest<span style="color: #009900;">&#40;</span>serverPage<span style="color: #339933;">,</span> objID<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">var</span> obj <span style="color: #339933;">=</span> document<span style="color: #339933;">.</span>getElementById<span style="color: #009900;">&#40;</span>objID<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">var</span> url <span style="color: #339933;">=</span> serverPage<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;?weight=&quot;</span><span style="color: #339933;">+</span>document<span style="color: #339933;">.</span>getElementById<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'weight'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>value<span style="color: #339933;">;</span>
xmlhttp<span style="color: #339933;">.</span>open<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;GET&quot;</span><span style="color: #339933;">,</span> url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
xmlhttp<span style="color: #339933;">.</span>onreadystatechange <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>xmlhttp<span style="color: #339933;">.</span>readyState <span style="color: #339933;">==</span> 4<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>xmlhttp<span style="color: #339933;">.</span>status <span style="color: #339933;">==</span> 200 <span style="color: #339933;">||</span> xmlhttp<span style="color: #339933;">.</span>status <span style="color: #339933;">==</span> 0<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
obj<span style="color: #339933;">.</span>value <span style="color: #339933;">=</span> xmlhttp<span style="color: #339933;">.</span>responseText<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
xmlhttp<span style="color: #339933;">.</span>send<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Itu idea saya, tp mungkin ada pembaca yang ada idea lain?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mdpai.com/tutorial-javascript/ajax-response-code-0/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
