<?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: Sending Javascript Functions Over JSON</title>
	<atom:link href="http://solutoire.com/2008/06/12/sending-javascript-functions-over-json/feed/" rel="self" type="application/rss+xml" />
	<link>http://solutoire.com/2008/06/12/sending-javascript-functions-over-json/</link>
	<description>Publicing platform</description>
	<lastBuildDate>Fri, 03 Feb 2012 08:33:37 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
	<item>
		<title>By: martin</title>
		<link>http://solutoire.com/2008/06/12/sending-javascript-functions-over-json/comment-page-1/#comment-22245</link>
		<dc:creator>martin</dc:creator>
		<pubDate>Wed, 27 Aug 2008 02:33:16 +0000</pubDate>
		<guid isPermaLink="false">http://solutoire.com/?p=172#comment-22245</guid>
		<description>Very good! Excellent post!</description>
		<content:encoded><![CDATA[<p>Very good! Excellent post!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ericH</title>
		<link>http://solutoire.com/2008/06/12/sending-javascript-functions-over-json/comment-page-1/#comment-18997</link>
		<dc:creator>ericH</dc:creator>
		<pubDate>Fri, 20 Jun 2008 16:50:08 +0000</pubDate>
		<guid isPermaLink="false">http://solutoire.com/?p=172#comment-18997</guid>
		<description>Link to an example in a Facebook app (you don&#039;t need to be logged in to see the graph). Ignore the app itself, it&#039;s still being developed.

Let me know if you are interested in using the php classes that makes it easy to create a graph like that using flotr.</description>
		<content:encoded><![CDATA[<p>Link to an example in a Facebook app (you don&#8217;t need to be logged in to see the graph). Ignore the app itself, it&#8217;s still being developed.</p>
<p>Let me know if you are interested in using the php classes that makes it easy to create a graph like that using flotr.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ericH</title>
		<link>http://solutoire.com/2008/06/12/sending-javascript-functions-over-json/comment-page-1/#comment-18995</link>
		<dc:creator>ericH</dc:creator>
		<pubDate>Fri, 20 Jun 2008 15:24:16 +0000</pubDate>
		<guid isPermaLink="false">http://solutoire.com/?p=172#comment-18995</guid>
		<description>thanks for the input, but i&#039;m afraid i don&#039;t quite understand what you&#039;re trying to do and therefore don&#039;t understand the problem.

i&#039;ve written a series of php helper classes to make the process of drawing AJAX graphs using flotr far easier, and I&#039;m hoping I can somehow pass them along so others can use them.

i&#039;ll post a link to an example of what they can do (and make simple for anyone to do!) sometime.</description>
		<content:encoded><![CDATA[<p>thanks for the input, but i&#8217;m afraid i don&#8217;t quite understand what you&#8217;re trying to do and therefore don&#8217;t understand the problem.</p>
<p>i&#8217;ve written a series of php helper classes to make the process of drawing AJAX graphs using flotr far easier, and I&#8217;m hoping I can somehow pass them along so others can use them.</p>
<p>i&#8217;ll post a link to an example of what they can do (and make simple for anyone to do!) sometime.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chris</title>
		<link>http://solutoire.com/2008/06/12/sending-javascript-functions-over-json/comment-page-1/#comment-18985</link>
		<dc:creator>chris</dc:creator>
		<pubDate>Fri, 20 Jun 2008 08:57:17 +0000</pubDate>
		<guid isPermaLink="false">http://solutoire.com/?p=172#comment-18985</guid>
		<description>just a problem with your solution :
$obj = array(
 &#039;str&#039; =&gt; &#039;%function%&#039;,
 &#039;function&#039; =&gt; &#039;function() {}&#039;
);
/*apply your solution*/
the result is : {&#039;str&#039;: function() {}, &#039;function&#039;:function() {}}

whereas we expect : {&#039;str&#039;: &#039;%function%&#039;, &#039;function&#039;:function() {}}

to solve the problem, do not use the array keys as the replacement key but a uuid

cheers</description>
		<content:encoded><![CDATA[<p>just a problem with your solution :<br />
$obj = array(<br />
 &#8216;str&#8217; =&gt; &#8216;%function%&#8217;,<br />
 &#8216;function&#8217; =&gt; &#8216;function() {}&#8217;<br />
);<br />
/*apply your solution*/<br />
the result is : {&#8216;str&#8217;: function() {}, &#8216;function&#8217;:function() {}}</p>
<p>whereas we expect : {&#8216;str&#8217;: &#8216;%function%&#8217;, &#8216;function&#8217;:function() {}}</p>
<p>to solve the problem, do not use the array keys as the replacement key but a uuid</p>
<p>cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ericH</title>
		<link>http://solutoire.com/2008/06/12/sending-javascript-functions-over-json/comment-page-1/#comment-18606</link>
		<dc:creator>ericH</dc:creator>
		<pubDate>Thu, 12 Jun 2008 20:09:32 +0000</pubDate>
		<guid isPermaLink="false">http://solutoire.com/?p=172#comment-18606</guid>
		<description>just incase it helps anyone out, i&#039;ll briefly explain how i got dates (or times) to show up on the axis and mouse tracker using a PHP server to dynamically build the graphs.

On your client page, add your javascript functions, such as:
&lt;pre class=&quot;javascript&quot;&gt;&lt;code&gt;function dateTickFormatter(date) {return xxYourFormattedDatexx;} 
along with 
function dateMoneyTrackFormatter(obj) { return dateTickFormatter(obj.x) + &#039;, $&#039; + obj.y ;} 
&lt;/code&gt;&lt;/pre&gt;

Next go to your PHP page that is creating the JSON, then set the helper arrays 

&lt;pre class=&quot;php&quot;&gt;&lt;code&gt;$value_arr[] = &#039;dateTickFormatter&#039;; $replace_keys[] = &#039;&quot;&#039; . &#039;%xtick%&#039; . &#039;&quot;&#039;; 
followed by the actual assignment to your class used to encode to json $graphdata-&gt;options-&gt;xaxis-&gt;tickFormatter = &#039;%xtick%&#039;; 
&lt;/code&gt;&lt;/pre&gt;

Next, do the same for the mouseTracker: 

&lt;pre class=&quot;php&quot;&gt;&lt;code&gt;$value_arr[] = &#039;dateMoneyTrackFormatter&#039;; $replace_keys[] = &#039;&quot;&#039; . &#039;%mousetrack%&#039; . &#039;&quot;&#039;; $graphdata-&gt;options-&gt;mouse-&gt;trackFormatter = &#039;%mousetrack%&#039;; 
&lt;/code&gt;&lt;/pre&gt;

after doing all your other graph assigments, encode the json &lt;code&gt;$json = json_encode($graphdata);&lt;/code&gt; and then simply use &lt;code&gt;$json = str_replace($replace_keys, $value_arr, $json);&lt;/code&gt; to put all the functions back into the json. It&#039;s pretty simple, but it took me a while to figure this out and hopefully I can save somebody the time. Sorry for the hard-to-read formatting, don&#039;t think I can control it here.</description>
		<content:encoded><![CDATA[<p>just incase it helps anyone out, i&#8217;ll briefly explain how i got dates (or times) to show up on the axis and mouse tracker using a PHP server to dynamically build the graphs.</p>
<p>On your client page, add your javascript functions, such as:</p>
<pre class="javascript"><code>function dateTickFormatter(date) {return xxYourFormattedDatexx;}
along with
function dateMoneyTrackFormatter(obj) { return dateTickFormatter(obj.x) + ', $' + obj.y ;}
</code></pre>
<p>Next go to your PHP page that is creating the JSON, then set the helper arrays </p>
<pre class="php"><code>$value_arr[] = 'dateTickFormatter'; $replace_keys[] = '"' . '%xtick%' . '"';
followed by the actual assignment to your class used to encode to json $graphdata-&gt;options-&gt;xaxis-&gt;tickFormatter = '%xtick%';
</code></pre>
<p>Next, do the same for the mouseTracker: </p>
<pre class="php"><code>$value_arr[] = 'dateMoneyTrackFormatter'; $replace_keys[] = '"' . '%mousetrack%' . '"'; $graphdata-&gt;options-&gt;mouse-&gt;trackFormatter = '%mousetrack%';
</code></pre>
<p>after doing all your other graph assigments, encode the json <code>$json = json_encode($graphdata);</code> and then simply use <code>$json = str_replace($replace_keys, $value_arr, $json);</code> to put all the functions back into the json. It&#8217;s pretty simple, but it took me a while to figure this out and hopefully I can save somebody the time. Sorry for the hard-to-read formatting, don&#8217;t think I can control it here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ericH</title>
		<link>http://solutoire.com/2008/06/12/sending-javascript-functions-over-json/comment-page-1/#comment-18604</link>
		<dc:creator>ericH</dc:creator>
		<pubDate>Thu, 12 Jun 2008 17:31:05 +0000</pubDate>
		<guid isPermaLink="false">http://solutoire.com/?p=172#comment-18604</guid>
		<description>thank you, i was trying to work around this issue for a couple hours yesterday and this is exactly what i needed!

can&#039;t thank you enough for such a quick and helpful reply...i&#039;ll be sure to return the favor.</description>
		<content:encoded><![CDATA[<p>thank you, i was trying to work around this issue for a couple hours yesterday and this is exactly what i needed!</p>
<p>can&#8217;t thank you enough for such a quick and helpful reply&#8230;i&#8217;ll be sure to return the favor.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

