<?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>Gargleblaster.org &#187; AJAX</title>
	<atom:link href="http://www.gargleblaster.org/tag/ajax/feed" rel="self" type="application/rss+xml" />
	<link>http://www.gargleblaster.org</link>
	<description></description>
	<lastBuildDate>Wed, 16 Jun 2010 08:34:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>AJAX with Safari</title>
		<link>http://www.gargleblaster.org/2006/12/15/ajax-with-safari.html</link>
		<comments>http://www.gargleblaster.org/2006/12/15/ajax-with-safari.html#comments</comments>
		<pubDate>Fri, 15 Dec 2006 11:03:47 +0000</pubDate>
		<dc:creator>Merlijn</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[XMLHttprequest]]></category>

		<guid isPermaLink="false">http://www.gargleblaster.org/?p=186</guid>
		<description><![CDATA[Mental note to myself: When making a POST request with XMLHttprequest and Safari(v2.0.4), always generate some content for the browser. If not, the status will always be undefined. example: if (!$mysqli->query($insert)) { trigger_error("error writing data: ".$insert); exit; } else { echo "0"; } This costed me some hours pulling my hair&#8230;. The following javascript works [...]]]></description>
			<content:encoded><![CDATA[<p>Mental note to myself:</p>
<p>When making a POST request with XMLHttprequest and Safari(v2.0.4), always generate some content for the browser. </p>
<p>If not, the status will always be <i>undefined</i>.<br />
example:</p>
<pre>if (!$mysqli->query($insert)) {
  trigger_error("error writing data: ".$insert);
  exit;
}
else {
  echo "0";
}
</pre>
<p>This costed me some hours pulling my hair&#8230;.<br />
The following javascript works like a charm when you return a &#8220;0&#8243; at the end of the php file called with POST. If you don&#8217;t return anything, Safari will decide that the HTTP headers are undefined and thus call the error handler.</p>
<pre>
KwAjax.ContentLoader.onReadyState=function(){
  var req=this.req;
  var ready=req.readyState;
  if (ready==KwAjax.READY_STATE_COMPLETE){
      var httpStatus=req.status;
      if (httpStatus == 200 || httpStatus == 0) {
        this.onload.call(this);
      }
      else {
        this.onerror.call(this);
      }
  }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.gargleblaster.org/2006/12/15/ajax-with-safari.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
