<?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>Web Dev Bros &#187; AJAX</title>
	<atom:link href="http://www.webdevbros.net/category/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webdevbros.net</link>
	<description>hot talk about web development</description>
	<lastBuildDate>Thu, 20 Jan 2011 19:55:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Your daily personalized RSS magazine</title>
		<link>http://www.webdevbros.net/2008/12/15/your-daily-personalized-rss-magazine/</link>
		<comments>http://www.webdevbros.net/2008/12/15/your-daily-personalized-rss-magazine/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 03:48:13 +0000</pubDate>
		<dc:creator>Michal</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[feeds]]></category>
		<category><![CDATA[hp]]></category>
		<category><![CDATA[magazine]]></category>
		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://www.webdevbros.net/?p=216</guid>
		<description><![CDATA[Today I found what I was looking for quite a while now: A magazine-like feed reader. Tabbloid (from HP!!!) is an online tool which lets you subscribe to your favorite feeds and delivers them bundled as a PDF magazine right to your mailbox. Its up to you if you want it daily or weekly. The [...]]]></description>
			<content:encoded><![CDATA[<p>Today I found what I was looking for quite a while now: A magazine-like feed reader. <a href="http://www.tabbloid.com">Tabbloid</a> (from HP!!!) is an online tool which lets you subscribe to your favorite feeds and delivers them bundled as a PDF magazine right to your mailbox. Its up to you if you want it daily or weekly. The whole service is pretty simple as it consists of only one form (which is fully ajaxed) and does not require any registration.  Now I&#8217;m proud to have an HP notebook ;)</p>
<p>I dont know about you guys, but I am having some feeds which I usually read on weekends cause they tend to write long detailed articles. Its them I&#8217;ve added to my magazine which is delivered right before the weekend every Friday noon. The days where I used to be sitting bored on my pool are over now :) Great idea, perfect solution! Google will follow soon ;)</p>
<p><a href='http://www.webdevbros.net/wp-content/uploads/2008/12/tabbloid.jpg'><img src="http://www.webdevbros.net/wp-content/uploads/2008/12/tabbloid.jpg" alt="" title="tabbloid" width="399" height="326" class="aligncenter size-full wp-image-217" /></a></p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.webdevbros.net/2008/12/15/your-daily-personalized-rss-magazine/&amp;t=Your+daily+personalized+RSS+magazine&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><iframe src='http://www.reddit.com/button_content?newwindow=1&amp;url=http://www.webdevbros.net/2008/12/15/your-daily-personalized-rss-magazine/&amp;title=Your+daily+personalized+RSS+magazine&amp;t=2 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http://www.webdevbros.net/2008/12/15/your-daily-personalized-rss-magazine/&amp;title=Your+daily+personalized+RSS+magazine&amp;t=1 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=Your+daily+personalized+RSS+magazine;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.webdevbros.net/2008/12/15/your-daily-personalized-rss-magazine/'; tweetmeme_style = 'normal';; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.webdevbros.net/2008/12/15/your-daily-personalized-rss-magazine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Translate easily with JavaScript and the Google language API</title>
		<link>http://www.webdevbros.net/2008/03/26/translate-easily-with-javascript-and-the-google-language-api/</link>
		<comments>http://www.webdevbros.net/2008/03/26/translate-easily-with-javascript-and-the-google-language-api/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 09:41:27 +0000</pubDate>
		<dc:creator>Michal</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://www.webdevbros.net/2008/03/26/translate-easily-with-javascript-and-the-google-language-api/</guid>
		<description><![CDATA[wow, google recently released an API for their translation services called Google language API. Thats a good news but it even gets better! The api is really easy to use and applications can be boosted within minutes. The reference can be found here Here is a quick example of how to translate something... PLAIN TEXT [...]]]></description>
			<content:encoded><![CDATA[<p>wow, google recently released an API for their translation services called <a href="http://code.google.com/apis/ajaxlanguage/documentation/">Google language API</a>. Thats a good news but it even gets better! The api is really easy to use and applications can be boosted within minutes. The reference can be found <a href="http://code.google.com/apis/ajaxlanguage/documentation/">here</a></p>
<p>Here is a quick example of how to translate something...</p>
<div class="igBar"><span id="ljavascript-3"><a href="#" onclick="javascript:showCodeTxt('javascript-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-3">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">google.<span style="color: #006600;">language</span>.<span style="color: #006600;">translate</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'my mum is swimming'</span>, <span style="color: #3366CC;">'en'</span>, <span style="color: #3366CC;">'de'</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>result<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span>result.<span style="color: #006600;">translation</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>and it gets better and even easier: its possible to let the API detect the language .. so nothing you have to take care about anymore.</p>
<div class="igBar"><span id="ljavascript-4"><a href="#" onclick="javascript:showCodeTxt('javascript-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-4">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">google.<span style="color: #006600;">language</span>.<span style="color: #006600;">detect</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'Deutsch ist auch eine Sprache'</span>,</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>result<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span>result.<span style="color: #006600;">language</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Further reading: <a href="http://googleajaxsearchapi.blogspot.com/2008/03/introducing-ajax-language-api-tools-for.html">An introduction to the language API and translation tools</a>.</p>
<p>Now its time to come up with some nice little tools, widgets which use this service. "a user selects a paragraph an your page, clicks a button and suddenly the text is translated into the desired language". </p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.webdevbros.net/2008/03/26/translate-easily-with-javascript-and-the-google-language-api/&amp;t=Translate+easily+with+JavaScript+and+the+Google+language+API&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><iframe src='http://www.reddit.com/button_content?newwindow=1&amp;url=http://www.webdevbros.net/2008/03/26/translate-easily-with-javascript-and-the-google-language-api/&amp;title=Translate+easily+with+JavaScript+and+the+Google+language+API&amp;t=2 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http://www.webdevbros.net/2008/03/26/translate-easily-with-javascript-and-the-google-language-api/&amp;title=Translate+easily+with+JavaScript+and+the+Google+language+API&amp;t=1 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=Translate+easily+with+JavaScript+and+the+Google+language+API;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.webdevbros.net/2008/03/26/translate-easily-with-javascript-and-the-google-language-api/'; tweetmeme_style = 'normal';; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.webdevbros.net/2008/03/26/translate-easily-with-javascript-and-the-google-language-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ajaxed 0.3 released</title>
		<link>http://www.webdevbros.net/2007/12/18/ajaxed-03-released/</link>
		<comments>http://www.webdevbros.net/2007/12/18/ajaxed-03-released/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 18:28:01 +0000</pubDate>
		<dc:creator>Michal</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ajaxed]]></category>
		<category><![CDATA[classic ASP (VBScript)]]></category>

		<guid isPermaLink="false">http://www.webdevbros.net/2007/12/18/ajaxed-03-released/</guid>
		<description><![CDATA[i have updated ajaxed (classic asp ajax library) to its 0.3 version. Thanks to all contributors who helped me with their feedback. Here are the updates... working with prototype 1.6 now working with JSON utility class 1.4 loading indicator stays now always on top of the screen. before it used to disappear if page scroll [...]]]></description>
			<content:encoded><![CDATA[<p>i have updated <a href="http://www.webdevbros.net/ajaxed/">ajaxed</a> (classic asp ajax library) to its 0.3 version. Thanks to all contributors who helped me with their feedback. Here are the updates...<span id="more-136"></span></p>
<ul>
<li>working with <a href="http://www.prototypejs.org/">prototype 1.6</a> now</li>
<li>working with <a href="http://www.webdevbros.net/2007/12/18/asp-json-utility-class-14-released/">JSON utility class 1.4</a></li>
<li>loading indicator stays now always on top of the screen. before it used to disappear if page scroll was not at the top</li>
<li>loading indicator has no styles by default anymore.. you have to be define them by yourself in your css file. definine the css class 'ajaxLoadingIndicator' and choose your custom style</li>
<li>more test have been added (also for recordsets)</li>
<li>added <code>AJAXED_DBCONNECTION</code> to the <code>config.asp</code> => you can open the DB connection automatically now for each page by default</li>
<li>renamed demo/index.asp to demo/default.asp because iis default installation has this already set</li>
</ul>
<p>upgrading to the new version should be no problem if you did not change the source files of the previous version. The only thing you need to change is to add styles for the loading indicator. This helps us that everyone has its own indicator style ;)</p>
<p>enjoy it <a href='http://www.webdevbros.net/wp-content/uploads/2007/12/ajaxed03.zip' title='ajaxed 0.3'>download ajaxed 0.3</a>. Please post you comments about the new version within this topic.</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.webdevbros.net/2007/12/18/ajaxed-03-released/&amp;t=ajaxed+0.3+released&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><iframe src='http://www.reddit.com/button_content?newwindow=1&amp;url=http://www.webdevbros.net/2007/12/18/ajaxed-03-released/&amp;title=ajaxed+0.3+released&amp;t=2 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http://www.webdevbros.net/2007/12/18/ajaxed-03-released/&amp;title=ajaxed+0.3+released&amp;t=1 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=ajaxed+0.3+released;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.webdevbros.net/2007/12/18/ajaxed-03-released/'; tweetmeme_style = 'normal';; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.webdevbros.net/2007/12/18/ajaxed-03-released/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>ajaxed: Calling server side VBScript procedures from client side (equivalent to PHP xajax)</title>
		<link>http://www.webdevbros.net/2007/07/02/ajaxed-calling-server-side-vbscript-procedures-from-client-side-equivalent-to-php-xajax/</link>
		<comments>http://www.webdevbros.net/2007/07/02/ajaxed-calling-server-side-vbscript-procedures-from-client-side-equivalent-to-php-xajax/#comments</comments>
		<pubDate>Sun, 01 Jul 2007 23:50:56 +0000</pubDate>
		<dc:creator>Michal</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[ajaxed]]></category>
		<category><![CDATA[classic ASP (VBScript)]]></category>
		<category><![CDATA[protoypejs]]></category>
		<category><![CDATA[xajax]]></category>

		<guid isPermaLink="false">http://www.webdevbros.net/2007/07/02/ajaxed-calling-server-side-vbscript-procedures-from-client-side-equivalent-to-php-xajax/</guid>
		<description><![CDATA[My last post (about an ASP RSS component) included a demonstration which made use of a cool ajax technique simply called "ajaxed". See the demonstration here again. If you play around you will recognize that there is no conventional postback and AJAX is up in here ;) I have developed a small "library" which easily [...]]]></description>
			<content:encoded><![CDATA[<p>My last post (about an ASP RSS component) included a demonstration which made use of a cool ajax technique simply called "ajaxed". <a href="http://www.grafix.at/webdevbros/RSS" target="_blank">See the demonstration here again.</a> If you play around you will recognize that there is no conventional postback and AJAX is up in here ;) I have developed a small "library" which easily allows you to call server side ASP VBScrtipt procedures from the client side. No low-level Ajax knowledge is required...<span id="more-78"></span><br />
Summarized it can be said that I have developed a bit similar thing for ASP like there is already for PHP (xajax - <a href="http://www.xajaxproject.org/">http://www.xajaxproject.org/</a>). It is not the same as xajax but it also allows you to call server side procedures from client side. We are all tired of the conventional postbacks which refresh the whole page, thats why we want ajax. I was tired of hacking all the lowlevel stuff for ajax and thought of a way to call the ASP procedures directly. With this and some stuff of my existing gabLibrary I have built a small library called "ajaxed". ajaxed just because it makes my pages ajaxed. Here is a very simple example which sums up two numbers (<a href="http://www.grafix.at/ajaxed/demo.asp" target="_blank">Try the demo here</a>):</p>
<div class="igBar"><span id="lasp-9"><a href="#" onclick="javascript:showCodeTxt('asp-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">ASP:</span>
<div id="asp-9">
<div class="asp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;!--#include virtual=<span style="color:#CC0000;">"/ajaxed/ajaxed.asp"</span>--&gt;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">&lt;%</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#990099; font-weight:bold;">set</span> page = <span style="color:#0000FF; font-weight:bold;">new</span> AjaxedPage</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">page.<span style="color:#9900CC;">draw</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">sub</span> init<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> : <span style="color:#990099; font-weight:bold;">end</span> <span style="color:#0000FF; font-weight:bold;">sub</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">sub</span> callback<span style="color:#006600; font-weight:bold;">&#40;</span>action<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">if</span> action = <span style="color:#CC0000;">"add"</span> <span style="color:#990099; font-weight:bold;">then</span> page.<span style="color:#9900CC;">return</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#330066;">add</span><span style="color:#006600; font-weight:bold;">&#40;</span>page.<span style="color:#9900CC;">RF</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"a"</span><span style="color:#006600; font-weight:bold;">&#41;</span>, page.<span style="color:#9900CC;">RF</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"b"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#990099; font-weight:bold;">end</span> <span style="color:#0000FF; font-weight:bold;">sub</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">function</span> <span style="color:#330066;">add</span><span style="color:#006600; font-weight:bold;">&#40;</span>a, b<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">if</span> <span style="color:#990099; font-weight:bold;">not</span> <span style="color:#990099; font-weight:bold;">isnumeric</span><span style="color:#006600; font-weight:bold;">&#40;</span>a<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#990099; font-weight:bold;">then</span> a = <span style="color:#800000;color:#800000;">0</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">if</span> <span style="color:#990099; font-weight:bold;">not</span> <span style="color:#990099; font-weight:bold;">isnumeric</span><span style="color:#006600; font-weight:bold;">&#40;</span>b<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#990099; font-weight:bold;">then</span> b = <span style="color:#800000;color:#800000;">0</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#330066;">add</span> = <span style="color:#990099; font-weight:bold;">cint</span><span style="color:#006600; font-weight:bold;">&#40;</span>a<span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color:#990099; font-weight:bold;">cint</span><span style="color:#006600; font-weight:bold;">&#40;</span>b<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#990099; font-weight:bold;">end</span> <span style="color:#0000FF; font-weight:bold;">function</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">sub</span> main<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#0000FF; font-weight:bold;">%&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;script&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">function</span> added<span style="color:#006600; font-weight:bold;">&#40;</span>sum<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#008000;">'c').value = sum;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">&lt;/script&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;form id=<span style="color:#CC0000;">"frm"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=<span style="color:#CC0000;">"Text"</span> name=<span style="color:#CC0000;">"a"</span> id=<span style="color:#CC0000;">"a"</span>&gt;+</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=<span style="color:#CC0000;">"Text"</span> name=<span style="color:#CC0000;">"b"</span> id=<span style="color:#CC0000;">"b"</span>&gt;=</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=<span style="color:#CC0000;">"Text"</span> name=<span style="color:#CC0000;">"c"</span> id=<span style="color:#CC0000;">"c"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;button onclick=<span style="color:#CC0000;">"ajaxed.callback('add', added)"</span> type=<span style="color:#CC0000;">"button"</span>&gt;calculate&lt;/button&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/form&gt;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">&lt;%</span> <span style="color:#990099; font-weight:bold;">end</span> <span style="color:#0000FF; font-weight:bold;">sub</span> <span style="color:#0000FF; font-weight:bold;">%&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>At first sight you can see that the calculation is done on server side ("add" function) and there is no classical XHR and not much JavaScript. The calculation is invoked through the button and therefore the button includes a JavaScript call which defines the "gateway" to the server side. Before I explain how the execution works, it is necessary to look at the page structure. The structure of an ajaxed page (as shown in the example) is the following:</p>
<ol>
<li>Loading ajaxed.asp (include)</li>
<li>Create an instance of the AjaxedPage class and execute draw()</li>
<li>Provide 3 methods:
<ol>
<li>init(): executed on every request (before main() or callback())</li>
<li>main(): executed when the page is ordinary called by a user</li>
<li>callback(): executed when the page calls itself again and requests a server side method (action)</li>
</ol>
</li>
</ol>
<p>The execution flow results as followed:</p>
<ol>
<li>init()</li>
<li>main() or callback()</li>
</ol>
<p>The whole trick here is that the page is able to make a request to itself. It has two states. One for the ordinary request of the user - which normally displays the user interface with (X)HTML. The other state is when the page requests itself again - which results in a JSON response. Ok lets forget the underlying technical details now...</p>
<p>The entry point in the example is the draw() method which draws the page and cares about everything for you. As already mentioned you need to provide the procedures init(), main() and a callback(action) in your page. Whereas init() is executed on every request the main() and callback() are never executed togehter. All the presentation should be put in the main() - you see the form in the example is in the main(). All security checks, preperations, initializations, etc should be put into the init() which is always executed before the main() and callback(action). When is the callback called? It is called if the ajaxed.callback JavaScript function is executed - which in this case is in the onclick event of the button. The ajaxed.callback requires an action (which is used as input for the server side callback function) and a JavaScript callback function which will be called after the server side process has been finished. This callback function (added) gets then the return of the server side function call. In this case with page.return(). The nice thing is that the page handles all conversions from the VBScript datatypes into the JavaScript equivalents (see <a href="/2007/04/26/generate-json-from-asp-datatypes">Generate JSON from ASP datatypes</a> if you are interested in the details). The page posts all form variables by default to the callback which means that the form fields are accessible via request.form within the callback. The AjaxedPage class offers several convenient utility methods to access the request collection. If you dont want to post the whole form or use your own parameters for the callback, you can use the third parameter of the ajaxed.callback function (with JSON). E.g.</p>
<div class="igBar"><span id="ljavascript-10"><a href="#" onclick="javascript:showCodeTxt('javascript-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-10">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ajaxed.<span style="color: #006600;">callback</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'serversideAction'</span>, jsCallback, <span style="color: #66cc66;">&#123;</span>param1:<span style="color: #CC0000;color:#800000;">1</span>, param2:<span style="color: #3366CC;">'michal'</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>With this technique its now possible to call all your server side procedures and then change the DOM according to the return value(s) from the server side. There is no need to care about any XHR or e.g. loading indication. Everything is handled. Another example?</p>
<p><strong>Populating dropdown from the database</strong></p>
<p>Lets assume we have a table called "table" which holds two columns named "id" and "name". We want to fill a dropdown with those values. id as the value and name as the displayed text. I have created a form which holds dropdown and a button. The button invokes the database call on server side. The callback then returns an ADODB.recordset which is automatically converted into an equivalent JavaScript data structure. The "got" JavaScript function can directly access the recordsets data. (Note: the "getRecordset" function does not exist and is just for demonstration)</p>
<div class="igBar"><span id="lasp-11"><a href="#" onclick="javascript:showCodeTxt('asp-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">ASP:</span>
<div id="asp-11">
<div class="asp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;!--#include virtual=<span style="color:#CC0000;">"/ajaxed/ajaxed.asp"</span>--&gt;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">&lt;%</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#990099; font-weight:bold;">set</span> page = <span style="color:#0000FF; font-weight:bold;">new</span> AjaxedPage</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">page.<span style="color:#9900CC;">draw</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">sub</span> init<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> : <span style="color:#990099; font-weight:bold;">end</span> <span style="color:#0000FF; font-weight:bold;">sub</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">sub</span> callback<span style="color:#006600; font-weight:bold;">&#40;</span>action<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">if</span> action = <span style="color:#CC0000;">"get"</span> <span style="color:#990099; font-weight:bold;">then</span> page.<span style="color:#9900CC;">return</span><span style="color:#006600; font-weight:bold;">&#40;</span>getRecordset<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"SELECT * FROM table"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#990099; font-weight:bold;">end</span> <span style="color:#0000FF; font-weight:bold;">sub</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">sub</span> main<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#0000FF; font-weight:bold;">%&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;script&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">function</span> got<span style="color:#006600; font-weight:bold;">&#40;</span>recs<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">for</span> <span style="color:#006600; font-weight:bold;">&#40;</span>i = <span style="color:#800000;color:#800000;">0</span>; i &lt;recs.<span style="color:#9900CC;">length</span>; i++<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">var</span> o = <span style="color:#0000FF; font-weight:bold;">new</span> <span style="color:#0000FF; font-weight:bold;">Option</span><span style="color:#006600; font-weight:bold;">&#40;</span>recs<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">name</span>, recs<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">id</span>, <span style="color:#0000FF; font-weight:bold;">false</span>, <span style="color:#0000FF; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#008000;">'dd').options[$('dd').options.length] = o;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">&lt;/script&gt;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;form id=<span style="color:#CC0000;">"frm"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;select id=<span style="color:#CC0000;">"dd"</span>&gt;&lt;/select&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;button onclick=<span style="color:#CC0000;">"ajaxed.callback('get', got)"</span> type=<span style="color:#CC0000;">"button"</span>&gt;load&lt;/button&gt;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/form&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">&lt;%</span> <span style="color:#990099; font-weight:bold;">end</span> <span style="color:#0000FF; font-weight:bold;">sub</span> <span style="color:#0000FF; font-weight:bold;">%&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>Returning more values with returnValue()</strong></p>
<p>The following example demonstrates that it is also possible to return more values on the callback. returnValue() allows to return more values by specifying each value with a name. return() in comparision can only return one value.</p>
<p><a href="http://www.grafix.at/webdevbros/ajaxed2.asp">Run the example</a></p>
<p>(It expects some value in the textbox. if no value is given then a "valid" flag is set to false and returned from server side. If some input is provided then an array additionally to the valid flag is returned. This example make not much sense but demonstrates the usage of more return values)</p>
<div class="igBar"><span id="lasp-12"><a href="#" onclick="javascript:showCodeTxt('asp-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">ASP:</span>
<div id="asp-12">
<div class="asp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;!--#include virtual=<span style="color:#CC0000;">"/ajaxed/ajaxed.asp"</span>--&gt;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">&lt;%</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#990099; font-weight:bold;">set</span> page = <span style="color:#0000FF; font-weight:bold;">new</span> AjaxedPage</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">page.<span style="color:#9900CC;">draw</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">sub</span> init<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> : <span style="color:#990099; font-weight:bold;">end</span> <span style="color:#0000FF; font-weight:bold;">sub</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">sub</span> callback<span style="color:#006600; font-weight:bold;">&#40;</span>action<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">if</span> action = <span style="color:#CC0000;">"do"</span> <span style="color:#990099; font-weight:bold;">then</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; page.<span style="color:#9900CC;">returnValue</span> <span style="color:#CC0000;">"valid"</span>, page.<span style="color:#9900CC;">RFHas</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"code"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">if</span> page.<span style="color:#9900CC;">RFHas</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"code"</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#990099; font-weight:bold;">then</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; page.<span style="color:#9900CC;">returnValue</span> <span style="color:#CC0000;">"even"</span>, <span style="color:#990099; font-weight:bold;">array</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">2</span>, <span style="color:#800000;color:#800000;">4</span>, <span style="color:#800000;color:#800000;">6</span>, <span style="color:#800000;color:#800000;">8</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">end</span> <span style="color:#990099; font-weight:bold;">if</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">end</span> <span style="color:#990099; font-weight:bold;">if</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#990099; font-weight:bold;">end</span> <span style="color:#0000FF; font-weight:bold;">sub</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">sub</span> main<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#0000FF; font-weight:bold;">%&gt;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;script&gt;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">function</span> done<span style="color:#006600; font-weight:bold;">&#40;</span>r<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>r.<span style="color:#9900CC;">valid</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">for</span> <span style="color:#006600; font-weight:bold;">&#40;</span>i = <span style="color:#800000;color:#800000;">0</span>; i &lt;r.<span style="color:#9900CC;">even</span>.<span style="color:#9900CC;">length</span>; i++<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#008000;">'vals').innerHTML += r.even[i] + &quot;&lt;br&gt;&quot;;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#990099; font-weight:bold;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alert<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"type in something!"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">&lt;/script&gt;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;form id=<span style="color:#CC0000;">"frm"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;div id=<span style="color:#CC0000;">"vals"</span>&gt;&lt;/div&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=<span style="color:#CC0000;">"Text"</span> name=<span style="color:#CC0000;">"code"</span> <span style="color:#330066;">value</span>=<span style="color:#CC0000;">""</span>&gt; <span style="color:#006600; font-weight:bold;">&#40;</span>type <span style="color:#990099; font-weight:bold;">in</span> something<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;button onclick=<span style="color:#CC0000;">"ajaxed.callback('do', done)"</span> type=<span style="color:#CC0000;">"button"</span>&gt;load&lt;/button&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/form&gt;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">&lt;%</span> <span style="color:#990099; font-weight:bold;">end</span> <span style="color:#0000FF; font-weight:bold;">sub</span> <span style="color:#0000FF; font-weight:bold;">%&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The concept makes use of <a href="www.prototypejs.org">Prototype JavaScript Library</a> and the <a href="/2007/04/26/generate-json-from-asp-datatypes">JSON utility class</a>.<br />
The ajaxed library includes those and therefore they can be used when working with ajaxed e.g. all features of Prototype. Furthermore it offers other convenient built-in features to ease the work with ASP pages (e.g. RFHas() method in the example above - it checks if agiven field from the request.form collection exists). Some other features of the Ajaxed page ...</p>
<ul>
<li>AjaxedPage.isPostback() - equivalent to asp.net postback</li>
<li>AjaxedPage.throwError() - generates an ASP user error</li>
<li>AjaxedPage.RFT() - gets a field from the request collection already trimmed</li>
<li>AjaxedPage.RFE() - gets a field from the request collection HTMLEncoded</li>
<li>AjaxedPage.loadJSFile() - ensures that JavaScript file is loaded only once</li>
<li>AjaxedPage.iif() - an VBScript inline if</li>
<li>AjaxedPage.getLocation() - gets the location of the page in several formats</li>
</ul>
<p><a href='/wp-content/uploads/2007/07/ajaxed01.zip' title='ajaxed 0.1'>Download ajaxed 0.1</a><br />
<a href='http://www.grafix.at/ajaxed/' title='ajaxed 0.1'>ajaxed 0.1 class reference</a></p>
<p><strong>Installation</strong></p>
<p>Download the zip archive and copy the whole "ajaxed" folder into your web root. Access the demo at  http://yourserver.com/ajaxed/demo/index.asp and check if everything works fine. There is a config.asp which provides some configurations.</p>
<p>Tell me what you think about it. I will come up with some more sophisticated examples in the future. cheeers...</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.webdevbros.net/2007/07/02/ajaxed-calling-server-side-vbscript-procedures-from-client-side-equivalent-to-php-xajax/&amp;t=ajaxed%3A+Calling+server+side+VBScript+procedures+from+client+side+%28equivalent+to+PHP+xajax%29&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><iframe src='http://www.reddit.com/button_content?newwindow=1&amp;url=http://www.webdevbros.net/2007/07/02/ajaxed-calling-server-side-vbscript-procedures-from-client-side-equivalent-to-php-xajax/&amp;title=ajaxed%3A+Calling+server+side+VBScript+procedures+from+client+side+%28equivalent+to+PHP+xajax%29&amp;t=2 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http://www.webdevbros.net/2007/07/02/ajaxed-calling-server-side-vbscript-procedures-from-client-side-equivalent-to-php-xajax/&amp;title=ajaxed%3A+Calling+server+side+VBScript+procedures+from+client+side+%28equivalent+to+PHP+xajax%29&amp;t=1 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=ajaxed%3A+Calling+server+side+VBScript+procedures+from+client+side+%28equivalent+to+PHP+xajax%29;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.webdevbros.net/2007/07/02/ajaxed-calling-server-side-vbscript-procedures-from-client-side-equivalent-to-php-xajax/'; tweetmeme_style = 'normal';; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.webdevbros.net/2007/07/02/ajaxed-calling-server-side-vbscript-procedures-from-client-side-equivalent-to-php-xajax/feed/</wfw:commentRss>
		<slash:comments>48</slash:comments>
		</item>
		<item>
		<title>Generate JSON from VBScript (ASP) datatypes</title>
		<link>http://www.webdevbros.net/2007/04/26/generate-json-from-asp-datatypes/</link>
		<comments>http://www.webdevbros.net/2007/04/26/generate-json-from-asp-datatypes/#comments</comments>
		<pubDate>Thu, 26 Apr 2007 16:18:26 +0000</pubDate>
		<dc:creator>Michal</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[ajaxed]]></category>
		<category><![CDATA[classic ASP (VBScript)]]></category>

		<guid isPermaLink="false">http://fabiankoehler.de/wdb/2007/04/26/generate-json-from-asp-datatypes/</guid>
		<description><![CDATA[When working with JSON it's nice to have a generator for your language which transforms all the datatypes from your chosen programming language into the JSON grammar so that you can use them within javascript. For a lot of popular languages it's done already (i suppose) but I haven't found one for classic ASP .. [...]]]></description>
			<content:encoded><![CDATA[<p>When working with JSON it's nice to have a generator for your language which transforms all the datatypes from your chosen programming language into the JSON grammar so that you can use them within javascript. For a lot of popular languages it's done already (i suppose) but I haven't found one for classic ASP .. so here it comes. The following example quickly demonstrates what the goal is:</p>
<div class="igBar"><span id="lasp-21"><a href="#" onclick="javascript:showCodeTxt('asp-21'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">ASP:</span>
<div id="asp-21">
<div class="asp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#990099; font-weight:bold;">set</span> RS = getRecordset<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"SELECT * FROM table"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#990099; font-weight:bold;">response</span>.<span style="color:#330066;">write</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">new</span> JSON<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">toJSON</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"rows"</span>, RS<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>A simple usage of JSON normally is that you create a page which outputs data as JSON as the only response. This page is called later from another page and the returned data is used within a javascript function (known as callback). So the snippet above gets some data from the database and stores it in an adodb.recordset which is passed then to the JSON generator and the result is printed on the page. The consuming page would like to access the data now as it originally was within the recordset. like this:</p>
<div class="igBar"><span id="ljavascript-22"><a href="#" onclick="javascript:showCodeTxt('javascript-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-22">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> callback<span style="color: #66cc66;">&#40;</span>rows<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span>i = <span style="color: #CC0000;color:#800000;">0</span>; i &lt;rows.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span>rows<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">columName</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>read on to get the details...<span id="more-35"></span></p>
<p>If you are already impressed by the short example then you will save a lot of time from now on when working with JSON. I have written a class which handles the whole conversation of classic ASP datatypes to JSON grammar. In particular an ASP boolean is recognized as a boolean within javascript, an integer as a number, an array as an array, a recordset as collection, etc. I will come back to the first example later but first another example:</p>
<div class="igBar"><span id="lasp-23"><a href="#" onclick="javascript:showCodeTxt('asp-23'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">ASP:</span>
<div id="asp-23">
<div class="asp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;script&gt;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;alert<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">&lt;%</span>= <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">new</span> JSON<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">toJSON</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"foo"</span>, <span style="color:#990099; font-weight:bold;">array</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">true</span>, <span style="color:#800000;color:#800000;">1</span>, <span style="color:#CC0000;">""</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#0000FF; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#0000FF; font-weight:bold;">%&gt;</span>.<span style="color:#9900CC;">foo</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">&lt;/script&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This short snippet displays an alert with true. As you can see we passed an ASP variable which has been recognized later by javascript. In this very example we even pass an array with 3 different datatypes (boolean, int and string). Those are all accessible within javascript.</p>
<p>Even nesting is fully supported. So array within arrays, dictionaries within arrays and vice versa. Mixing is allowed in every way you imagine. This example demonstrates what i am talking about:</p>
<div class="igBar"><span id="lasp-24"><a href="#" onclick="javascript:showCodeTxt('asp-24'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">ASP:</span>
<div id="asp-24">
<div class="asp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">&lt;%</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#990099; font-weight:bold;">set</span> d = <span style="color:#990099; font-weight:bold;">server</span>.<span style="color:#330066;">createObject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"scripting.dictionary"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">d.<span style="color:#330066;">add</span> <span style="color:#CC0000;">"en"</span>, <span style="color:#CC0000;">"sausage"</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">d.<span style="color:#330066;">add</span> <span style="color:#CC0000;">"de"</span>, <span style="color:#990099; font-weight:bold;">array</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"egal"</span>, <span style="color:#CC0000;">"wurst"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">%&gt;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;script&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;alert<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">&lt;%</span>= <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">new</span> JSON<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">toJSON</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"foo"</span>, <span style="color:#990099; font-weight:bold;">array</span><span style="color:#006600; font-weight:bold;">&#40;</span>d<span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#0000FF; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#0000FF; font-weight:bold;">%&gt;</span>.<span style="color:#9900CC;">foo</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">de</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">&lt;/script&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>We've created a dictionary (which consists of two value pairs - one holds just a string (sausage) and the other an array (egal, wurst)) and we've added this into another array which is the value of "foo". After toJSON has generated the JSON string we can access the whole structure and the alertbox says "wurst".</p>
<p>Now back to the example of the introduction. We can even pass whole recordsets to the generator which will generate a datastructure as followed:</p>
<p><strong>JSON representation for ADODB.recordset</strong></p>
<p>a recordset with two columns ID and LASTNAME will be converted into a javascript array where each field represents a row in the field and the row provides properties which are named the same as the columns within the recordset. That means that iterating through data within javascript is not a mission anymore ... look at this example:</p>
<div class="igBar"><span id="lasp-25"><a href="#" onclick="javascript:showCodeTxt('asp-25'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">ASP:</span>
<div id="asp-25">
<div class="asp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;script&gt;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;alert<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">&lt;%</span>= <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">new</span> JSON<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">toJSON</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"data"</span>, getRecordset<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"SELECT id, lastname FROM table"</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#0000FF; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#0000FF; font-weight:bold;">%&gt;</span>.<span style="color:#9900CC;">data</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">lastname</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">&lt;/script&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>We transfered the whole adodb.recordset from ASP to javascript using JSON. How cool is that!? </p>
<p><strong>Custom classes</strong></p>
<p>If you create your own classes within VBScript then you might like the automatic conversion of your objects into a JSON representation. As VBScript does not support introspection (reflection) it is necessary to built an own work around. If you want the JSON class to recognize your custom objects it is necessary to implement a reflect() method within the custom type. reflect() must return a dictionary with all properties where each key is the property name and the value is its value. Values can be all kind of types (because its resolved recursively anyway). The following example shows a "Person" class which implements reflect() and therefore can be used within the JSON generator:</p>
<div class="igBar"><span id="lasp-26"><a href="#" onclick="javascript:showCodeTxt('asp-26'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">ASP:</span>
<div id="asp-26">
<div class="asp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">class</span> Person</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">public</span> firstname&nbsp; &nbsp; <span style="color:#008000;">''[string] firstname</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">public</span> lastname&nbsp;<span style="color:#008000;">''[string] lastname</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">public</span> favNumbers&nbsp; &nbsp;<span style="color:#008000;">''[array] persons favorite numbers</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">public</span> <span style="color:#0000FF; font-weight:bold;">function</span> reflect<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">set</span> reflect = <span style="color:#990099; font-weight:bold;">server</span>.<span style="color:#330066;">createObject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"scripting.dictionary"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">with</span> reflect</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color:#330066;">add</span> <span style="color:#CC0000;">"firstname"</span>, firstname</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color:#330066;">add</span> <span style="color:#CC0000;">"lastname"</span>, lastname</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color:#330066;">add</span> <span style="color:#CC0000;">"favNumbers"</span>, favNumbers</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">end</span> <span style="color:#990099; font-weight:bold;">with</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">end</span> <span style="color:#0000FF; font-weight:bold;">function</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#990099; font-weight:bold;">end</span> <span style="color:#0000FF; font-weight:bold;">class</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The following example access the properties of the VBScript Person class within JavaScript (as it would be a JavaScript object).</p>
<div class="igBar"><span id="lasp-27"><a href="#" onclick="javascript:showCodeTxt('asp-27'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">ASP:</span>
<div id="asp-27">
<div class="asp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">&lt;%</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#990099; font-weight:bold;">set</span> p = <span style="color:#0000FF; font-weight:bold;">new</span> Person</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">p.<span style="color:#9900CC;">firstname</span> = <span style="color:#CC0000;">"John"</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">p.<span style="color:#9900CC;">lastname</span> = <span style="color:#CC0000;">"Doe"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">p.<span style="color:#9900CC;">favNumbers</span> = <span style="color:#990099; font-weight:bold;">array</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">2</span>, <span style="color:#800000;color:#800000;">7</span>, <span style="color:#800000;color:#800000;">234</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">%&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;script&gt;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;alert<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">&lt;%</span>= <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">new</span> JSON<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">toJSON</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"p"</span>, p, <span style="color:#0000FF; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#0000FF; font-weight:bold;">%&gt;</span>.<span style="color:#9900CC;">p</span>.<span style="color:#9900CC;">favNumbers</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">&lt;/script&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>Update 10.07.2008:</strong> as the <code>toJSON()</code> method has been defined as default method it can be used much quicker by leaving the methodname out:</p>
<div class="igBar"><span id="lasp-28"><a href="#" onclick="javascript:showCodeTxt('asp-28'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">ASP:</span>
<div id="asp-28">
<div class="asp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;script&gt;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;alert<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">&lt;%</span>= <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">new</span> JSON<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"root"</span>, <span style="color:#CC0000;">"some value"</span>, <span style="color:#0000FF; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#0000FF; font-weight:bold;">%&gt;</span>.<span style="color:#9900CC;">root</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">&lt;/script&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Those examples are really straight forward and should just demonstrate how to use the generator. Normally you don't really deal with that as a client, you'd rather have some nice classes which do all this stuff for you. In another article I will demonstrate how to combine ASP, JSON and AJAX in a nice and effective way...</p>
<p>The download of the class is at the bottom. Here is a list of the features..</p>
<ul>
<li>Transforms various datatypes from ASP to Javascript using JSON</li>
<li>Escapes all characters which needs to be escaped according to JSON's RFC</li>
<li>Recursively inspects the values so nesting of values is supported</li>
<li>Results can be returned or (for better performance) written directly to the response</li>
</ul>
<p>Have fun with it. There are other article related to this topic which might be interested for you:</p>
<ul>
<li><a href="/2007/04/26/json-character-escaping-function-in-classic-asp">JSON character escaping function in classic ASP</a></il>
<li><a href="/category/classic-asp/ajaxed/">ajaxed Library - calling server side ASP code directly from client side.</a></li>
</ul>
<p><strong>Download latest JSON ASP utility class:</strong><br />
<a href="http://www.webdevbros.net/wp-content/uploads/2008/07/json151.zip">JSON 1.5.1</a> (<a href='http://www.webdevbros.net/wp-content/uploads/2008/07/jsondoc.html' title='JSON documentation'>JSON documentation</a>)</p>
<p><strong>License:</strong><br />
Use it for whatever you want but be sure to leave the credits to the creator(s) within the code. If you don't change it you can get always the latest update here ;)</p>
<p><strong>Change Log:</strong><br />
<a href="http://www.webdevbros.net/wp-content/uploads/2008/07/json151.zip">v1.5.1</a> (15.07.2008)</p>
<ul>
<li>bugfix: didnt work properly with empty dictionaries. fixed!</li>
</ul>
<p><a href="http://www.webdevbros.net/wp-content/uploads/2008/07/json15.zip">v1.5</a> (10.07.2008)</p>
<ul>
<li>bugfix: utf-8 fully supported now (e.g. chinese didnt work)</li>
<li>bugfix: empty dictionaries werent represented. now represented as 'null'</li>
<li>toJSON() is defined as default method</li>
<li>paged recordsets supported</li>
<li>asp request object, IStringList and IRequestDictionary supported</li>
<li>updated documentation</li>
<li><a href="http://www.webdevbros.net/2008/07/10/asp-json-utility-version-15-released/">detailed information (examples, ...) about the changes</a></li>
</ul>
<p><a href='http://www.webdevbros.net/wp-content/uploads/2007/12/json141.zip' title='JSON 1.4.1'>v1.4.1</a> (19.12.2007)</p>
<ul>
<li>minor bugfix immediately after the 1.4 release</li>
</ul>
<p>v1.4 (18.12.2007)</p>
<ul>
<li>there used to be an error when returning custom objects which were processed recursively. it resulted in outputing only '}'. this has been fixed.</li>
<li>vartype 19 was not recognized as integer, but is now (comes from mysql)</li>
<li>vartype 7 was not recognized as float, but is now</li>
</ul>
<p>v1.3 (21.08.2007)</p>
<ul>
<li>Option Explicit can be used now</li>
<li>Multidimensional arrays are supported (unlimited dimensions)</li>
</ul>
<p>v1.2 (19.07.2007)</p>
<ul>
<li>Nested dictionaries were are not generated with toResponse = false. Fixed</li>
<li>Currency and Byte datatype were not generated correctly. Fixed</li>
</ul>
<p>v1.1 (17.05.2007)</p>
<ul>
<li>Bug with Floats has been fixed</li>
</ul>
<table style="background-color: #fff; padding: 5px;" cellspacing=0>
<tr>
<td>
  <img src="http://groups.google.com/groups/img/3nb/groups_bar_de.gif" height=26 width=132 alt="Google Groups">
  </td>
</tr>
<tr>
<td style="padding-left: 5px;font-size: 125%">
  <b>asp-ajaxed</b>
  </td>
</tr>
<tr>
<td style="padding-left: 5px"> <a href="http://groups.google.com/group/asp-ajaxed">JSON is part of ajaxed. So you can check the ajaxed discussion group for more discussion about it.</a> </td>
</tr>
</table>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.webdevbros.net/2007/04/26/generate-json-from-asp-datatypes/&amp;t=Generate+JSON+from+VBScript+%28ASP%29+datatypes+&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><iframe src='http://www.reddit.com/button_content?newwindow=1&amp;url=http://www.webdevbros.net/2007/04/26/generate-json-from-asp-datatypes/&amp;title=Generate+JSON+from+VBScript+%28ASP%29+datatypes+&amp;t=2 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http://www.webdevbros.net/2007/04/26/generate-json-from-asp-datatypes/&amp;title=Generate+JSON+from+VBScript+%28ASP%29+datatypes+&amp;t=1 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=Generate+JSON+from+VBScript+%28ASP%29+datatypes+;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.webdevbros.net/2007/04/26/generate-json-from-asp-datatypes/'; tweetmeme_style = 'normal';; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.webdevbros.net/2007/04/26/generate-json-from-asp-datatypes/feed/</wfw:commentRss>
		<slash:comments>181</slash:comments>
		</item>
		<item>
		<title>JSON character escaping function in classic ASP</title>
		<link>http://www.webdevbros.net/2007/04/26/json-character-escaping-function-in-classic-asp/</link>
		<comments>http://www.webdevbros.net/2007/04/26/json-character-escaping-function-in-classic-asp/#comments</comments>
		<pubDate>Thu, 26 Apr 2007 10:14:51 +0000</pubDate>
		<dc:creator>Michal</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[classic ASP (VBScript)]]></category>

		<guid isPermaLink="false">http://fabiankoehler.de/wdb/?p=32</guid>
		<description><![CDATA[If you are into advanced AJAX techniques you probably will stumble across JSON (www.json.org) which makes developing (and therefore the life) a lot easier when working with AJAX. If you already stumbled across and you use JSON within classic ASP you might find this article useful. It deals with escaping characters for JSON acording to the RFC4627#2.5 I haven't found any snippet out there [...]]]></description>
			<content:encoded><![CDATA[<p>If you are into advanced AJAX techniques you probably will stumble across JSON (<a href="http://www.json.org/">www.json.org</a>) which makes developing (and therefore the life) a lot easier when working with AJAX. If you already stumbled across and you use JSON within classic ASP you might find this article useful. It deals with escaping characters for JSON acording to the <a target="_blank" href="http://www.ietf.org/rfc/rfc4627.txt?number=4627">RFC4627#2.5</a><span id="more-32"></span></p>
<p>I haven't found any snippet out there for classic ASP so we had to write our own. And so my work colleague - an old algorithm guru - just came up with this function which covers all the requirements specified in the JSON RFC.</p>
<p>What we want to achieve...</p>
<div class="igBar"><span id="lasp-32"><a href="#" onclick="javascript:showCodeTxt('asp-32'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">ASP:</span>
<div id="asp-32">
<div class="asp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;script&gt;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  alert<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#123;</span>foo:<span style="color:#CC0000;">"&lt;%= "</span>some va<span style="color:#CC0000;">""</span>lue<span style="color:#CC0000;">" %&gt;"</span><span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">foo</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">&lt;/script&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The code snippet above will result in a javascript error because we are passing an apostrophe from ASP to Javascript which leads to an early closing of the string: foo:"some va"lue" (there is one apostrophe too much). The same thing happens for other characters as well. If you have line breaks, german umlaute, hidden special characters, etc. All those need to be escaped now in order that the javascript simple object notation (JSON) can interpret it. Thats the function which does the escaping (there are 3 more functions cause they're used within the escapeJSON()):</p>
<div class="igBar"><span id="lasp-33"><a href="#" onclick="javascript:showCodeTxt('asp-33'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">ASP:</span>
<div id="asp-33">
<div class="asp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">'******************************************************************************************</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">'' @SDESCRIPTION:&nbsp; &nbsp;takes a given string and makes it JSON valid (http://json.org/)</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">'' @AUTHOR:&nbsp;Michael Rebec</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">'' @DESCRIPTION:&nbsp; &nbsp; all characters which needs to be escaped are beeing replaced by their</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">''&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; unicode representation according to the </span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">''&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RFC4627#2.5 - http://www.ietf.org/rfc/rfc4627.txt?number=4627</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">'' @PARAM:&nbsp; &nbsp; &nbsp; val [string]: value which should be escaped</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">'' @RETURN:&nbsp;&nbsp;&nbsp;[string] JSON valid string</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">'******************************************************************************************</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#990099; font-weight:bold;">public</span> <span style="color:#0000FF; font-weight:bold;">function</span> escapeJSON<span style="color:#006600; font-weight:bold;">&#40;</span>val<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; cDoubleQuote = &amp;h22</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; cRevSolidus = &amp;h5C</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; cSolidus = &amp;h2F</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">for</span> i = <span style="color:#800000;color:#800000;">1</span> <span style="color:#990099; font-weight:bold;">to</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#990099; font-weight:bold;">len</span><span style="color:#006600; font-weight:bold;">&#40;</span>val<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; currentDigit = <span style="color:#990099; font-weight:bold;">mid</span><span style="color:#006600; font-weight:bold;">&#40;</span>val, i, <span style="color:#800000;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">if</span> asc<span style="color:#006600; font-weight:bold;">&#40;</span>currentDigit<span style="color:#006600; font-weight:bold;">&#41;</span>&gt; &amp;h00 <span style="color:#0000FF; font-weight:bold;">and</span> asc<span style="color:#006600; font-weight:bold;">&#40;</span>currentDigit<span style="color:#006600; font-weight:bold;">&#41;</span> &lt;&amp;h1F <span style="color:#990099; font-weight:bold;">then</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentDigit = escapeJSONSquence<span style="color:#006600; font-weight:bold;">&#40;</span>currentDigit<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">elseif</span> asc<span style="color:#006600; font-weight:bold;">&#40;</span>currentDigit<span style="color:#006600; font-weight:bold;">&#41;</span>&gt;= &amp;hC280 <span style="color:#0000FF; font-weight:bold;">and</span> asc<span style="color:#006600; font-weight:bold;">&#40;</span>currentDigit<span style="color:#006600; font-weight:bold;">&#41;</span> &lt;= &amp;hC2BF <span style="color:#990099; font-weight:bold;">then</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentDigit = <span style="color:#CC0000;">"<span style="color:#000099; font-weight:bold;">\u</span>00"</span> + <span style="color:#990099; font-weight:bold;">right</span><span style="color:#006600; font-weight:bold;">&#40;</span>padLeft<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#990099; font-weight:bold;">hex</span><span style="color:#006600; font-weight:bold;">&#40;</span>asc<span style="color:#006600; font-weight:bold;">&#40;</span>currentDigit<span style="color:#006600; font-weight:bold;">&#41;</span> - &amp;hC200<span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#800000;color:#800000;">2</span>, <span style="color:#800000;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#800000;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">elseif</span> asc<span style="color:#006600; font-weight:bold;">&#40;</span>currentDigit<span style="color:#006600; font-weight:bold;">&#41;</span>&gt;= &amp;hC380 <span style="color:#0000FF; font-weight:bold;">and</span> asc<span style="color:#006600; font-weight:bold;">&#40;</span>currentDigit<span style="color:#006600; font-weight:bold;">&#41;</span> &lt;= &amp;hC3BF <span style="color:#990099; font-weight:bold;">then</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentDigit = <span style="color:#CC0000;">"<span style="color:#000099; font-weight:bold;">\u</span>00"</span> + <span style="color:#990099; font-weight:bold;">right</span><span style="color:#006600; font-weight:bold;">&#40;</span>padLeft<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#990099; font-weight:bold;">hex</span><span style="color:#006600; font-weight:bold;">&#40;</span>asc<span style="color:#006600; font-weight:bold;">&#40;</span>currentDigit<span style="color:#006600; font-weight:bold;">&#41;</span> - &amp;hC2C0<span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#800000;color:#800000;">2</span>, <span style="color:#800000;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#800000;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">else</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">select</span> <span style="color:#990099; font-weight:bold;">case</span> asc<span style="color:#006600; font-weight:bold;">&#40;</span>currentDigit<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">case</span> cDoubleQuote: currentDigit = escapeJSONSquence<span style="color:#006600; font-weight:bold;">&#40;</span>currentDigit<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">case</span> cRevSolidus: currentDigit = escapeJSONSquence<span style="color:#006600; font-weight:bold;">&#40;</span>currentDigit<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">case</span> cSolidus: currentDigit = escapeJSONSquence<span style="color:#006600; font-weight:bold;">&#40;</span>currentDigit<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">end</span> <span style="color:#990099; font-weight:bold;">select</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">end</span> <span style="color:#990099; font-weight:bold;">if</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; escapeJSON = escapeJSON &amp; currentDigit</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">next</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#990099; font-weight:bold;">end</span> <span style="color:#0000FF; font-weight:bold;">function</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">function</span> escapeJSONSquence<span style="color:#006600; font-weight:bold;">&#40;</span>digit<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; escapeJSONSquence = <span style="color:#CC0000;">"<span style="color:#000099; font-weight:bold;">\u</span>00"</span> + <span style="color:#990099; font-weight:bold;">right</span><span style="color:#006600; font-weight:bold;">&#40;</span>padLeft<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#990099; font-weight:bold;">hex</span><span style="color:#006600; font-weight:bold;">&#40;</span>asc<span style="color:#006600; font-weight:bold;">&#40;</span>digit<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#800000;color:#800000;">2</span>, <span style="color:#800000;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#800000;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#990099; font-weight:bold;">end</span> <span style="color:#0000FF; font-weight:bold;">function</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">function</span> padLeft<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#330066;">value</span>, totalLength, paddingChar<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; padLeft = <span style="color:#990099; font-weight:bold;">right</span><span style="color:#006600; font-weight:bold;">&#40;</span>clone<span style="color:#006600; font-weight:bold;">&#40;</span>paddingChar, totalLength<span style="color:#006600; font-weight:bold;">&#41;</span> &amp; <span style="color:#330066;">value</span>, totalLength<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#990099; font-weight:bold;">end</span> <span style="color:#0000FF; font-weight:bold;">function</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#990099; font-weight:bold;">public</span> <span style="color:#0000FF; font-weight:bold;">function</span> clone<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#990099; font-weight:bold;">byVal</span> str, n<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#990099; font-weight:bold;">for</span> i = <span style="color:#800000;color:#800000;">1</span> <span style="color:#990099; font-weight:bold;">to</span> n : clone = clone &amp; str : <span style="color:#990099; font-weight:bold;">next</span></div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#990099; font-weight:bold;">end</span> <span style="color:#0000FF; font-weight:bold;">function</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>So now we should be able to escape the strings for JSON like this and no error should occur...</p>
<div class="igBar"><span id="lasp-34"><a href="#" onclick="javascript:showCodeTxt('asp-34'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">ASP:</span>
<div id="asp-34">
<div class="asp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;script&gt;</div>
</li>
<li style="font-weight: bold;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  alert<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#123;</span>foo:<span style="color:#CC0000;">"&lt;%= escapeJSON("</span>some va<span style="color:#CC0000;">""</span>lue<span style="color:#CC0000;">") %&gt;"</span><span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">foo</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#767676;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF; font-weight:bold;">&lt;/script&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This stuff has been tested and works for all characters so everything can be transfered with JSON now ;) I would suggest to group the whole functions into a class called JSON with a method escape() just for a nicer use. In my case its in a utility class StringOperations where I have several string manipulation methods. If you are interested you can download the full String class also which include the JSON escaping method:</p>
<p><a href="/wp-content/uploads/2007/04/string.zip" title="StringOperations 0.9">StringOperations 0.9</a> (<a target="_blank" href="/wp-content/uploads/2007/04/stringoperations.html" title="StringOperations Documentation">StringOperations Documentation</a>)</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.webdevbros.net/2007/04/26/json-character-escaping-function-in-classic-asp/&amp;t=JSON+character+escaping+function+in+classic+ASP&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><iframe src='http://www.reddit.com/button_content?newwindow=1&amp;url=http://www.webdevbros.net/2007/04/26/json-character-escaping-function-in-classic-asp/&amp;title=JSON+character+escaping+function+in+classic+ASP&amp;t=2 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http://www.webdevbros.net/2007/04/26/json-character-escaping-function-in-classic-asp/&amp;title=JSON+character+escaping+function+in+classic+ASP&amp;t=1 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td> <td><script type="text/javascript"><!--yahooBuzzArticleHeadline=JSON+character+escaping+function+in+classic+ASP;//--></script><script type="text/javascript" src="http://d.yimg.com/ds/badge2.js" badgetype=square></script></td> <td><script type="text/javascript">tweetmeme_url='http://www.webdevbros.net/2007/04/26/json-character-escaping-function-in-classic-asp/'; tweetmeme_style = 'normal';; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.webdevbros.net/2007/04/26/json-character-escaping-function-in-classic-asp/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

