<?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>Amphee Web Tech Pvt. Ltd.</title>
	<atom:link href="http://blog.amphee.com/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.amphee.com</link>
	<description></description>
	<lastBuildDate>Wed, 04 May 2011 05:34:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		
	
	<!-- google ad injected by adsense-optimizer http://www.adsenseoptimizer.de -->
	<div  style="padding:3px; display: block; margin-left: auto; margin-right: auto; text-align: center;"><!-- Ad number: 1 --><script type="text/javascript"><!--
    	 
    	google_ad_client = "pub-0687753067406098"; google_alternate_color = "FFFFFF";
		google_ad_width = 468; google_ad_height = 60;
		google_ad_format = "468x60_as"; google_ad_type = "text_image";
		google_ad_channel =""; google_color_border = "A6C9E2";
		google_color_link = "FF3019"; google_color_bg = "FFFFFF";
		google_color_text = "000000"; google_color_url = "7EB544";
		google_ui_features = "rc:0"; //--></script>
		<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div>	<item>
		<title>Adding Search Engine Optimisation To Your Online Marketing Mix</title>
		<link>http://blog.amphee.com/index.php/2011/05/04/adding-search-engine-optimisation-to-your-online-marketing-mix/</link>
		<comments>http://blog.amphee.com/index.php/2011/05/04/adding-search-engine-optimisation-to-your-online-marketing-mix/#comments</comments>
		<pubDate>Wed, 04 May 2011 05:33:04 +0000</pubDate>
		<dc:creator>kiran vadariya</dc:creator>
				<category><![CDATA[marketing]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[online marketing mix]]></category>
		<category><![CDATA[search engine optiomization]]></category>
		<category><![CDATA[seo and marketing]]></category>

		<guid isPermaLink="false">http://blog.amphee.com/?p=385</guid>
		<description><![CDATA[Search engine optimization is a  cost effective way to drive organic traffic to your website, and as web  users conduct billions of searches every single day using sites like  Google and Yahoo, it is clear that SEO should be considered a part of every website’s online marketing mix.  The best marketers [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Search engine optimization is a  cost effective way to drive organic traffic to your website, and as web  users conduct billions of searches every single day using sites like  Google and Yahoo, it is clear that SEO should be considered a part of every website’s online marketing mix.  The best marketers know that diversification is key to success so  combining search engine optimization with paid linking and PPC can  provide a stable basis of traffic and should your search rankings drop  you will have other advertising to pick up some of the slack.</p>
<p><strong>Search Engine Optimization<br />
</strong></p>
<p>The use of the most suitable keywords and ongoing link building  efforts can help to drive literally thousands of visitors to your  website every single day. While some of the more competitive keywords  will take months to start performing and generating traffic, niche and  long tail keywords can deliver results in a matter of weeks as long as  you approach your search engine optimisation properly.</p>
<p><strong>Pay Per Click Marketing</strong></p>
<p>During the early days of your SEO campaign, while you are still  developing traffic and identifying link sources, you can use paid  marketing techniques to pick up the slack. PPC, or Pay Per Click  advertising, for example can deliver traffic to web pages instantly.  Register with a PPC UK network, write your ad, place your bids, and  watch your ads appear on relevant websites.</p>
<p><strong>Other Forms Of Paid Marketing</strong></p>
<p>You can also use banner advertising, affiliate advertising, paid  links, paid reviews, and other paid marketing techniques too. All of  these techniques offer varying degrees of success to different websites.  While some pages will benefit from banner advertising others will not  and while one site may generate a lot of interest through paid reviews,  other sites may not carry the right type of product to enjoy success  down this marketing avenue.</p>
<p><strong>Continued Marketing</strong></p>
<p>Once your search engine optimization efforts begin to bear fruit you  can begin to wind down your paid marketing efforts, although if any are  showing great success and a positive Return on Investment then you  should seriously consider keeping them going.</p>
<p><strong>Search Engine Optimization<br />
</strong></p>
<p>Search engine optimization is generally considered a long term method for generating <a href="http://www.seo.uk.com/">website seo</a> traffic but that doesn’t necessarily mean you have to wait years to  start reaping the rewards. Start early in the life cycle of your website,  create good quality and well optimized page content, and start building  beneficial and relevant links and you’ll soon start to see your organic  search engine traffic levels rise.</p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.amphee.com/index.php/2011/05/04/adding-search-engine-optimisation-to-your-online-marketing-mix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Cross-Platform Table Naming</title>
		<link>http://blog.amphee.com/index.php/2011/01/27/mysql-cross-platform-table-naming/</link>
		<comments>http://blog.amphee.com/index.php/2011/01/27/mysql-cross-platform-table-naming/#comments</comments>
		<pubDate>Thu, 27 Jan 2011 13:54:57 +0000</pubDate>
		<dc:creator>kiran vadariya</dc:creator>
				<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://blog.amphee.com/?p=382</guid>
		<description><![CDATA[The upper, lower, or camel-casing of MySQL table names is rarely  something developers consider. Unfortunately, it can cause major  headaches if you are intending to port your application from a Windows  or Mac development environment to a Linux or Unix-based host.
Table Name Case Sensitivity
Each table in a MySQL database corresponds to a [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>The upper, lower, or camel-casing of MySQL table names is rarely  something developers consider. Unfortunately, it can cause major  headaches if you are intending to port your application from a Windows  or Mac development environment to a Linux or Unix-based host.</p>
<h2>Table Name Case Sensitivity</h2>
<p>Each table in a MySQL database corresponds to a physical .frm file  within the database folder. Therefore, the case sensitivity of your  tables relies on the underlying Operating System. For example, assume we  have created the following table and filled it with data:</p>
<p>CREATE MyTable (<br />
id SMALLINT unsigned NOT NULL,<br />
name VARCHAR(50)<br />
)</p>
<p>We then run the following query in our code:</p>
<p>SELECT id, name FROM mytable WHERE id = 1;</p>
<p>This query will work correctly on a Windows or Mac host.  Unfortunately, it will fail once your application is copied to Linux or  Unix.</p>
<p>Note that database, table, and trigger names are affected by case  sensitivity. Columns, indexes, stored procedures, event names and  aliases are not case-sensitive.</p>
<h2>lower_case_table_names</h2>
<p><strong>lower_case_table_names</strong> is a MySQL system variable  which controls how the database resolves table name casing. It can be  passed as a start-up parameter for mysqld or within my.ini (although  this is known to cause earlier versions of MySQL to fail). The value can  be set to:</p>
<p><strong>0</strong> <em>(Linux/Unix default)</em><br />
Table name comparisons are case sensitive. Tables are stored on disk using the letter case specified.</p>
<p><strong>1</strong> <em>(Windows default)</em><br />
Table name comparisons are not case sensitive. MySQL converts all table names to lowercase on storage and lookup.</p>
<p><strong>2</strong> <em>(Mac default)</em><br />
Table name comparisons are not case sensitive. MyISAM tables are stored  on disk using the letter case specified, but MySQL converts them to  lowercase on lookup. InnoDB tables are stored in lowercase.</p>
<p>It is therefore tempting to set lower_case_table_names to zero on your system. However, Windows users should <strong>not</strong> do that. The manual warns that if you set lower-case-table-names=0 on a  case-insensitive file system and access MyISAM table names using  different letter cases, index corruption may result. Nasty.</p>
<h2>Recommendations</h2>
<p>Personally, I prefer to use lowercase naming conventions for all  databases, tables, indexes, keys and other MySQL names. That appears to  be the easiest solution.</p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.amphee.com/index.php/2011/01/27/mysql-cross-platform-table-naming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speed Up Your Website With PHP Buffer Flushing</title>
		<link>http://blog.amphee.com/index.php/2011/01/24/speed-up-your-website-with-php-buffer-flushing/</link>
		<comments>http://blog.amphee.com/index.php/2011/01/24/speed-up-your-website-with-php-buffer-flushing/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 07:02:04 +0000</pubDate>
		<dc:creator>kiran vadariya</dc:creator>
				<category><![CDATA[php development]]></category>
		<category><![CDATA[flush()]]></category>
		<category><![CDATA[php buffer flushing]]></category>
		<category><![CDATA[speed up your website with php]]></category>

		<guid isPermaLink="false">http://blog.amphee.com/?p=371</guid>
		<description><![CDATA[PHP output buffering is normally enabled by default. In older versions of PHP, a string would be sent to your browser every time the interpreter encountered an echo statement or text outside the PHP delimiters.
Output buffering makes this process quicker and more efficient. The buffer is essentially a big memory-resident string. When text is output, [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>PHP output buffering is normally enabled by default. In older versions of PHP, a string would be sent to your browser every time the interpreter encountered an echo statement or text outside the PHP delimiters.</p>
<p>Output buffering makes this process quicker and more efficient. The buffer is essentially a big memory-resident string. When text is output, it’s appended to the buffer rather than returned to the browser immediately. The buffer is then “flushed”, i.e. its contents are transmitted and the string is reset pending further output. Flushing occurs when:</p>
<p>1. the PHP interpreter reaches the end of the page<br />
2. the buffer exceeds the number of bytes specified within PHP’s output_buffering configuration setting, or<br />
3. the flush() or ob_flush() functions are called.</p>
<p>There are a few caveats but, assuming it works within your environment, you should consider flushing the buffer immediately after the page’s tag, e.g.</p>
<p>&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221; &#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt;<br />
&lt;html xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221;&gt;<br />
&lt;BODY&gt;<br />
This page is loading.&lt;br /&gt;<br />
&lt;?php flush(); sleep(2); ?&gt;<br />
Almost there&#8230;&lt;br /&gt;<br />
&lt;?php flush(); sleep(2); ?&gt;<br />
Done.&lt;br /&gt;<br />
&lt;/BODY&gt;<br />
&lt;/HTML&gt;</p>
<p>(If you’re using WordPress, you could use similar code in your theme’s header.php file.)</p>
<p>Once the browser has received the HTML head, it can begin to download all linked CSS files, favicons and other resources. These downloads can occur while the browser is idle and waiting for the main body content.</p>
<p>The speed increase will depend on the server-side processing required, the weight of your page, the quantity and size of your CSS files, and whether the browser has cached any resources. However, it’s such a simple optimization, there’s little reason not to do it.</p>
<p>I’d be interested to know whether this technique results in a perceivable speed difference on your website or application.</p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.amphee.com/index.php/2011/01/24/speed-up-your-website-with-php-buffer-flushing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	
	
	<!-- google ad injected by adsense-optimizer http://www.adsenseoptimizer.de -->
	<div  style="padding:7px; display: block; margin-left: auto; margin-right: auto; text-align: center;"><!-- Ad number: 2 --><script type="text/javascript"><!--
    	 
    	google_ad_client = "pub-0687753067406098"; google_alternate_color = "FFFFFF";
		google_ad_width = 468; google_ad_height = 60;
		google_ad_format = "468x60_as"; google_ad_type = "text_image";
		google_ad_channel =""; google_color_border = "E3FA11";
		google_color_link = "FFFFFF"; google_color_bg = "A2AB2B";
		google_color_text = "000000"; google_color_url = "FFFFFF";
		google_ui_features = "rc:0"; //--></script>
		<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div>	<item>
		<title>32 Tips To Speed Up Your MySQL Queries</title>
		<link>http://blog.amphee.com/index.php/2011/01/18/32-tips-to-speed-up-your-mysql-queries/</link>
		<comments>http://blog.amphee.com/index.php/2011/01/18/32-tips-to-speed-up-your-mysql-queries/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 11:58:33 +0000</pubDate>
		<dc:creator>kiran vadariya</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[32 Tips To Speed Up Your MySQL Queries]]></category>
		<category><![CDATA[MySQL Queries]]></category>

		<guid isPermaLink="false">http://blog.amphee.com/?p=363</guid>
		<description><![CDATA[If you are interested in how to create fast MySQL queries, this article is for you

Use persistent connections to the database to avoid connection overhead.
Check all tables have PRIMARY KEYs on columns with high cardinality  (many rows match the key value). Well,`gender` column has low  cardinality (selectivity), unique user id column has high [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>If you are interested in how to create fast MySQL queries, this article is for you</p>
<ol>
<li>Use persistent connections to the database to avoid connection overhead.</li>
<li>Check all tables have PRIMARY KEYs on columns with high cardinality  (many rows match the key value). Well,`gender` column has low  cardinality (selectivity), unique user id column has high one and is a  good candidate to become a primary key.</li>
<li>All references between different tables should usually be done with  indices (which also means they must have identical data types so that  joins based on the corresponding columns will be faster). Also check  that fields that you often need to search in (appear frequently in  WHERE, ORDER BY or GROUP BY clauses) have indices, but don’t add too  many: the worst thing you can do is to add an index on every column of a  table  (I haven’t seen a table with more than 5 indices for a table,  even 20-30 columns big). If you never refer to a column in comparisons,  there’s no need to index it.</li>
<li>Using simpler permissions when you issue GRANT statements enables  MySQL to reduce permission-checking overhead when clients execute  statements.</li>
<li>Use less RAM per row by declaring columns only as large as they need to be to hold the values stored in them.</li>
<li>Use leftmost index prefix — in MySQL you can define index on several  columns so that left part of that index can be used a separate one so  that you need less indices.</li>
<li>When your index consists of many columns, why not to create a hash  column which is short, reasonably unique, and indexed? Then your query  will look like: <textarea cols="60" rows="3" name="code">SELECT * FROM table WHERE hash_column = MD5( CONCAT(col1, col2) ) AND col1=&#8217;aaa&#8217; AND col2=&#8217;bbb&#8217;; </textarea></li>
<li>Consider running <a rel="nofollow" href="http://dev.mysql.com/doc/refman/5.0/en/analyze-table.html" target="_blank">ANALYZE TABLE</a> (or myisamchk &#8211;analyze from command line) on a table after it has been loaded with data to help MySQL better optimize queries.</li>
<li>Use CHAR type when possible (instead of VARCHAR, BLOB or TEXT) —  when values of a column have constant length: MD5-hash (32 symbols),  ICAO or IATA airport code (4 and 3 symbols), BIC bank code (3 symbols),  etc. Data in CHAR columns can be found faster rather than in variable  length data types columns.</li>
<li>Don’t split a table if you just have too many columns. In accessing a  row, the biggest performance hit is the disk seek needed to find the  first byte of the row.</li>
<li>A column must be declared as NOT NULL if it really is — thus you speed up table traversing a bit.</li>
<li>If you usually retrieve rows in the same order like expr1, expr2, &#8230;, make <a rel="nofollow" href="http://dev.mysql.com/doc/refman/5.0/en/alter-table.html" target="_blank">ALTER TABLE &#8230; ORDER BY expr1, expr2</a>, &#8230; to optimize the table.</li>
<li>Don’t use PHP loop to fetch rows from database one by one just because you can  — use IN instead, e.g. <textarea cols="60" rows="3" name="code">SELECT * FROM `table` WHERE `id` IN (1,7,13,42); </textarea></li>
<li>Use column default value, and insert only those values that differs from the default. This reduces the query parsing time.</li>
<li>Use <a rel="nofollow" href="http://dev.mysql.com/doc/refman/5.0/en/insert-delayed.html" target="_blank">INSERT DELAYED</a> or <a rel="nofollow" href="http://dev.mysql.com/doc/refman/5.0/en/insert.html" target="_blank">INSERT LOW_PRIORITY</a> (for MyISAM) to write to your change log table. Also, if it’s MyISAM,  you can add DELAY_KEY_WRITE=1 option — this makes index updates faster  because they are not flushed to disk until the table is closed.</li>
<li>Think of storing users sessions data (or any other non-critical data) in <a rel="nofollow" href="http://dev.mysql.com/doc/refman/5.0/en/memory-storage-engine.html" target="_blank">MEMORY</a> table — it’s very fast.</li>
<li>For your web application, images and other binary assets should  normally be stored as files. That is, store only a reference to the file  rather than the file itself in the database.</li>
<li>If you have to store big amounts of textual data, consider using  BLOB column to contain compressed data (MySQL’s COMPRESS() seems to be  slow, so gzipping at PHP side may help) and decompressing the contents  at application server side. Anyway, it must be benchmarked.</li>
<li>If you often need to calculate COUNT or SUM based on information  from a lot of rows (articles rating, poll votes, user registrations  count, etc.), it makes sense to create a separate table and update the  counter in real time, which is much faster. If you need to collect  statistics from huge log tables, take advantage of using a summary table  instead of scanning the entire log table every time.</li>
<li>Don’t use <a rel="nofollow" href="http://dev.mysql.com/doc/refman/5.0/en/replace.html" target="_blank">REPLACE</a> (which is DELETE+INSERT and wastes ids): use <a rel="nofollow" href="http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html" target="_blank">INSERT … ON DUPLICATE KEY UPDATE</a> instead (i.e. it’s INSERT + UPDATE if conflict takes place). The same  technique can be used when you need first make a SELECT to find out if  data is already in database, and then run either INSERT or UPDATE. Why  to choose yourself — rely on database side.</li>
<li>Tune MySQL caching: allocate enough memory for the buffer (e.g. SET GLOBAL <a rel="nofollow" href="http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_query_cache_size" target="_blank">query_cache_size</a> = 1000000) and <a rel="nofollow" href="http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_query_cache_min_res_unit" target="_blank">define query_cache_min_res_unit</a> depending on average query resultset size.</li>
<li>Divide complex queries into several simpler ones — they have more chances to be cached, so will be quicker.</li>
<li>Group several similar <code>INSERT</code>s in one long <code>INSERT</code> with multiple <code>VALUES</code> lists to insert several rows at a time: quiry will be quicker due to  fact that connection + sending + parsing a query takes 5-7 times of  actual data insertion (depending on row size). If that is not possible,  use <a rel="nofollow" href="http://dev.mysql.com/doc/refman/5.0/en/commit.html" target="_blank"><code>START TRANSACTION</code> and <code>COMMIT</code></a>, if your database is InnoDB, otherwise use <a rel="nofollow" href="http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html" target="_blank"><code>LOCK TABLES</code></a> — this benefits performance because the index buffer is flushed to disk only once, after all <code>INSERT</code> statements have completed; in this case unlock your tables each 1000 rows or so to allow other threads access to the table.</li>
<li>When loading a table from a text file, use <a rel="nofollow" href="http://dev.mysql.com/doc/refman/5.0/en/load-data.html" target="_blank">LOAD DATA INFILE</a> (or <a rel="nofollow" href="http://i1t2b3.com/2009/01/14/quick-csv-import-with-mapping/" target="_blank">my tool</a> for that), it’s 20-100 times faster.</li>
<li><a rel="nofollow" href="http://dev.mysql.com/doc/refman/5.0/en/slow-query-log.html" target="_blank">Log slow queries</a> on your dev/beta environment and investigate them. This way you can  catch queries which execution time is high, those that don’t use  indexes, and also — slow administrative statements (like OPTIMIZE TABLE  and ANALYZE TABLE)</li>
<li>Tune your database <a rel="nofollow" href="http://dev.mysql.com/doc/refman/5.1/en/server-parameters.html" target="_blank">server parameters</a>: for example, increase buffers size.</li>
<li>If you have lots of DELETEs in your application, or updates of  dynamic format rows (if you have VARCHAR, BLOB or TEXT column, the row  has dynamic format) of your MyISAM table to a longer total length (which  may split the row), schedule running <a rel="nofollow" href="http://dev.mysql.com/doc/refman/5.0/en/optimize-table.html" target="_blank">OPTIMIZE TABLE</a> query every weekend by crond. Thus you make the defragmentation, which  means more speed of queries. If you don’t use replication, add LOCAL  keyword to make it faster.</li>
<li>Don’t use ORDER BY RAND() to fetch several random rows. Fetch 10-20  entries (last by time added or ID) and make array_random() on PHP side.  There are also <a rel="nofollow" href="http://jan.kneschke.de/projects/mysql/order-by-rand/" target="_blank">other solutions</a>.</li>
<li>Consider avoiding using of HAVING clause — it’s rather slow.</li>
<li>In most cases, a DISTINCT clause can be considered as a special case of GROUP BY; so the <a rel="nofollow" href="http://dev.mysql.com/doc/refman/5.1/en/group-by-optimization.html" target="_blank">optimizations applicable to GROUP BY queries</a> can be also applied to queries with a DISTINCT clause. Also, if you use  DISTINCT, try to use LIMIT (MySQL stops as soon as it finds row_count  unique rows) and avoid ORDER BY (it requires a temporary table in many  cases).</li>
<li>When I read “Building scalable web sites”, I found that it worth  sometimes to de-normalise some tables (Flickr does this), i.e. duplicate  some data in several tables to avoid JOINs which are expensive. You can  support data integrity with foreign keys or triggers.</li>
<li>If you want to test a specific MySQL function or expression, use <a rel="nofollow" href="http://dev.mysql.com/doc/refman/5.1/en/information-functions.html#function_benchmark" target="_blank">BENCHMARK</a> function to do that.</li>
</ol>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.amphee.com/index.php/2011/01/18/32-tips-to-speed-up-your-mysql-queries/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>How to fix xhtml and css validation errors in Virtuemart</title>
		<link>http://blog.amphee.com/index.php/2010/11/16/how-to-fix-xhtml-and-css-validation-errors-in-virtuemart/</link>
		<comments>http://blog.amphee.com/index.php/2010/11/16/how-to-fix-xhtml-and-css-validation-errors-in-virtuemart/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 10:36:30 +0000</pubDate>
		<dc:creator>kiran vadariya</dc:creator>
				<category><![CDATA[virtuemart]]></category>
		<category><![CDATA[virtuemart blog post]]></category>

		<guid isPermaLink="false">http://blog.amphee.com/?p=360</guid>
		<description><![CDATA[There are essentially two issues causing the xhtml &#38; css not to validate.
How to fix the css validation
The css validation error is due to the use of text-align:top in the “Featured Products” block on the shop landing page. The issue   being that “top” is not a valid option for the text-align property.  [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>There are essentially two issues causing the xhtml &amp; css not to validate.</p>
<h2>How to fix the css validation</h2>
<p>The css validation error is due to the use of <strong>text-align:top</strong> in the “Featured Products” block on the shop landing page. The issue   being that “top” is not a valid option for the text-align property.   Valid options for text-align are:</p>
<ul>
<li>left</li>
<li>center</li>
<li>right</li>
<li>justify</li>
<li>inherit</li>
</ul>
<p>The correct usage to set the <strong>vertical alignment</strong> is… yup, you guessed it “<strong>vertical-align</strong>“.</p>
<p><em>(Read more about the differences between css vertical-align property and css text-align property)</em></p>
<p>The file that needs to be updated in Virtuemart is located in:<br />
[site-root] &gt; components &gt; com_virtuemart &gt; themes &gt; default &gt; templates &gt; common &gt; <strong>featuredProducts.tpl.php</strong></p>
<p><strong>Line 15, change from this:</strong></p>
<pre>&lt;div style="float:left;width:&lt;?php echo $cellwidth ?&gt;%;text-align:top;padding:0px;" &gt;</pre>
<p><strong>To this:</strong></p>
<pre>&lt;div style="float:left;width:&lt;?php echo $cellwidth ?&gt;%;vertical-align:top;padding:0;" &gt;</pre>
<h2>How to fix the xhtml validation</h2>
<p>The second problem causing the xhtml validation to fail was also in   the Featured Products file. This time caused by the product title h4, a   block level element, being wrapped by a link, which is an inline   element.</p>
<p>This can be fixed in two ways:</p>
<p>The first is to <strong>reverse the nesting</strong>, so the link is inside of the heading.</p>
<h5>Line 16, change from this:</h5>
<pre>&lt;a title="&lt;?php echo $featured["product_name"] ?&gt;" href="&lt;?php $sess-&gt;purl(URL."index.php?option=com_virtuemart&amp;amp;page=shop.product_details&amp;amp;flypage=".$featured["flypage"]."&amp;amp;product_id=".$featured["product_id"]) ?&gt;"&gt;</pre>
<h5>To this:</h5>
<pre>&lt;h4&gt;&lt;a title="&lt;?php echo $featured["product_name"] ?&gt;" href="&lt;?php $sess-&gt;purl(URL."index.php?option=com_virtuemart&amp;amp;page=shop.product_details&amp;amp;flypage=".$featured["flypage"]."&amp;amp;product_id=".$featured["product_id"]) ?&gt;"&gt;</pre>
<p>The second option is to <strong>change the product title from an h4 to an inline element</strong>, such as a span. I personally prefer the first method, as using a heading brings more structure to the page.</p>
<h2>How to fix the final xhtml validation errors</h2>
<p>The last few xhtml validation errors we caused by the use of   ampersands (ie, &amp;) in the stores categories, for example Laptops   &amp; Accessories. I tried using the full entity code (ie, &amp;amp;)   but the error prevailed.</p>
<p>The quick and easy fix was to simply use the full word ‘and’ instead.   This isn’t the most ideal fix, but it works. A better solution would  be  to add a simple string replace function to replace all instances of   &amp; with the full entity code, like Joomla! does with its menus.</p>
<p>Hope this comes in handy in your next Virtuemart project!</p>
<p>You c an find original post here : <a href="http://www.prothemer.com/blog/tips-and-tricks/virtuemart-xhtml-css-validation-errors/" target="_blank">http://www.prothemer.com/blog/tips-and-tricks/virtuemart-xhtml-css-validation-errors/</a></p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.amphee.com/index.php/2010/11/16/how-to-fix-xhtml-and-css-validation-errors-in-virtuemart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Virtuemart] Customize Order List &#8211; adding extra column</title>
		<link>http://blog.amphee.com/index.php/2010/11/16/virtuemart-customize-order-list-adding-extra-column/</link>
		<comments>http://blog.amphee.com/index.php/2010/11/16/virtuemart-customize-order-list-adding-extra-column/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 06:39:10 +0000</pubDate>
		<dc:creator>kiran vadariya</dc:creator>
				<category><![CDATA[virtuemart]]></category>
		<category><![CDATA[virtuemart blog post]]></category>

		<guid isPermaLink="false">http://blog.amphee.com/?p=357</guid>
		<description><![CDATA[In this post, I am going explain on how to add an extra column in Virtuemart Administrator Order List page.
(Note that, in this example, I&#8217;m going to add a new address_1 column).
Note: Please refer to my previous post on &#8220;adding search keywords&#8221; for the SQL query code for the other fields that you want.
Getting Started.
In [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>In this post, I am going explain on how to add an extra column in Virtuemart Administrator Order List page.</p>
<p>(Note that, in this example, I&#8217;m going to add a new address_1 column).</p>
<p>Note: Please refer to my previous post on &#8220;adding search keywords&#8221; for the SQL query code for the other fields that you want.</p>
<p><strong>Getting Started.</strong></p>
<p>In /administrator/components/com_virtuemart/html/order.order_list.php</p>
<p>locate this section, around line 27. Then add &#8220;address_1&#8243; into the line, as below.</p>
<div>
<div><code>//$list .= "first_name, last_name FROM #__{vm}_orders, #__{vm}_order_user_info WHERE ";</code></div>
<div><code>// This is the modified line.</code></div>
<div><code>$list</code> <code>.= </code><code>"first_name, last_name, address_1 FROM #__{vm}_orders, #__{vm}_order_user_info WHERE "</code><code>;</code></div>
</div>
<p>After that, locate this section, as usual and note that &#8220;Address_1&#8243; is already the added column.</p>
<div>
<div><code>$columns</code> <code>= Array( </code><code>"#"</code> <code>=&gt; </code><code>"width=\"20\""</code><code>, </code></div>
<div><code> </code><code>"&lt;input type=\"checkbox\" name=\"toggle\" value=\"\" onclick=\"checkAll("</code><code>.</code><code>$checklimit</code><code>.</code><code>")\" /&gt;"</code> <code>=&gt; </code><code>"width=\"20\""</code><code>,</code></div>
<div><code> </code><code>$VM_LANG</code><code>-&gt;_(</code><code>'PHPSHOP_ORDER_LIST_ID'</code><code>) =&gt; </code><code>''</code><code>,</code></div>
<div><code> </code><code>$VM_LANG</code><code>-&gt;_(</code><code>'PHPSHOP_ORDER_PRINT_NAME'</code><code>) =&gt; </code><code>''</code><code>,</code></div>
<div><code> </code><code>// This is you "address_1" column header,</code></div>
<div><code> </code><code>'Address_1'</code> <code>=&gt; </code><code>''</code><code>,</code></div>
<div><code> </code><code>$VM_LANG</code><code>-&gt;_(</code><code>'PHPSHOP_ORDER_LIST_PRINT_LABEL'</code><code>) =&gt; </code><code>''</code><code>,</code></div>
<div><code> </code><code>$VM_LANG</code><code>-&gt;_(</code><code>'PHPSHOP_ORDER_LIST_TRACK'</code><code>) =&gt; </code><code>''</code><code>,</code></div>
<div><code> </code><code>$VM_LANG</code><code>-&gt;_(</code><code>'PHPSHOP_ORDER_LIST_VOID_LABEL'</code><code>) =&gt; </code><code>''</code><code>,</code></div>
<div><code> </code><code>$VM_LANG</code><code>-&gt;_(</code><code>'PHPSHOP_CHECK_OUT_THANK_YOU_PRINT_VIEW'</code><code>) =&gt; </code><code>''</code><code>,</code></div>
<div><code> </code><code>$VM_LANG</code><code>-&gt;_(</code><code>'PHPSHOP_ORDER_LIST_CDATE'</code><code>) =&gt; </code><code>''</code><code>,</code></div>
<div><code> </code><code>$VM_LANG</code><code>-&gt;_(</code><code>'PHPSHOP_ORDER_LIST_MDATE'</code><code>) =&gt; </code><code>''</code><code>,</code></div>
<div><code> </code><code>$VM_LANG</code><code>-&gt;_(</code><code>'PHPSHOP_ORDER_LIST_STATUS'</code><code>) =&gt; </code><code>''</code><code>,</code></div>
<div><code> </code><code>$VM_LANG</code><code>-&gt;_(</code><code>'PHPSHOP_UPDATE'</code><code>) =&gt; </code><code>''</code><code>,</code></div>
<div><code> </code><code>$VM_LANG</code><code>-&gt;_(</code><code>'PHPSHOP_ORDER_LIST_TOTAL'</code><code>) =&gt; </code><code>''</code><code>,</code></div>
<div><code> </code><code>$VM_LANG</code><code>-&gt;_(</code><code>'E_REMOVE'</code><code>) =&gt; </code><code>"width=\"5%\""</code></div>
<div><code> </code><code>);</code></div>
<div><code>$listObj</code><code>-&gt;writeTableHeader( </code><code>$columns</code> <code>);</code></div>
</div>
<div></div>
<div></div>
<p>As you can see, those are the column headers for the table, and the last line is the function to print out all the column headers.</p>
<p>Then, you will need to locate this section of code, and add $db-&gt;f(&#8216;address_1&#8242;); as below:</p>
<div>
<div><code>$tmp_cell</code> <code>= </code><code>$db</code><code>-&gt;f(</code><code>'first_name'</code><code>).</code><code>' '</code><code>.</code><code>$db</code><code>-&gt;f(</code><code>'last_name'</code><code>);</code></div>
<div><code> </code><code>if</code><code>( </code><code>$perm</code><code>-&gt;check(</code><code>'admin'</code><code>) &amp;&amp; defined(</code><code>'_VM_IS_BACKEND'</code><code>)) {</code></div>
<div><code> </code><code>$url</code> <code>= </code><code>$_SERVER</code><code>[</code><code>'PHP_SELF'</code><code>].</code><code>"?page=admin.user_form&amp;amp;user_id="</code><code>. </code><code>$db</code><code>-&gt;f(</code><code>"user_id"</code><code>);</code></div>
<div><code> </code><code>$tmp_cell</code> <code>= </code><code>'&lt;a href="'</code><code>.</code><code>$sess</code><code>-&gt;url( </code><code>$url</code> <code>).</code><code>'"&gt;'</code><code>.</code><code>$tmp_cell</code><code>.</code><code>'&lt;/a&gt;'</code><code>;</code></div>
<div><code> </code><code>}</code></div>
<div><code> </code></div>
<div><code> </code><code>$listObj</code><code>-&gt;addCell( </code><code>$tmp_cell</code> <code>);</code></div>
<div><code> </code><code>// This will print "address_1" column, which is placed afer the "Name" column</code></div>
<div><code> </code><code>$tmp_cell</code> <code>= </code><code>$db</code><code>-&gt;f(</code><code>'address_1'</code><code>);</code></div>
<div><code> </code><code>$listObj</code><code>-&gt;addCell( </code><code>$tmp_cell</code> <code>);</code></div>
<div></div>
</div>
<p>Note: The ordering of the the print cell function (i.e. the $listObj-&gt;addCell( $tmp_cell ); ) is important, as you wouldn&#8217;t want to jumble up the different fields.Thats all.</p>
<p>Hope this help <img src='http://blog.amphee.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>You can find the original post here : <a href="http://blog.gbinghan.com/2010/10/virtuemart-customize-order-list-adding.html" target="_blank">http://blog.gbinghan.com/2010/10/virtuemart-customize-order-list-adding.html</a></p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.amphee.com/index.php/2010/11/16/virtuemart-customize-order-list-adding-extra-column/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loading external content with Ajax using jQuery and YQL</title>
		<link>http://blog.amphee.com/index.php/2010/11/15/loading-external-content-with-ajax-using-jquery-and-yql/</link>
		<comments>http://blog.amphee.com/index.php/2010/11/15/loading-external-content-with-ajax-using-jquery-and-yql/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 06:17:10 +0000</pubDate>
		<dc:creator>kiran vadariya</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[ajax and jquery blog post]]></category>

		<guid isPermaLink="false">http://blog.amphee.com/?p=321</guid>
		<description><![CDATA[Ajax with jQuery is very easy to do – like most solutions it is a few lines:
$(document).ready(function(){
$('.ajaxtrigger').click(function(){
$('#target').load('ajaxcontent.html');
});
});
Check out this simple and obtrusive Ajax demo to see what it does.
This will turn all elements with the class of ajaxtrigger into triggers to load “ajaxcontent.html” and display its contents in the element with the ID target.
This is [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Ajax with jQuery is very easy to do – like most solutions it is a few lines:</p>
<pre><code>$(document).ready(function(){
$('.ajaxtrigger').click(function(){
$('#target').load('ajaxcontent.html');
});
});</code></pre>
<p>Check out this <a href="http://icant.co.uk/articles/crossdomain-ajax-with-jquery/simple-ajax.html">simple and obtrusive Ajax demo</a> to see what it does.</p>
<p>This will turn all elements with the class of <code>ajaxtrigger</code> into triggers to load “ajaxcontent.html” and display its contents in the element with the ID <code>target</code>.</p>
<p>This is terrible, as it most of the time means that people will use pointless links like <code>&lt;a href="#"&gt;click me&lt;/a&gt;</code>,  but this is not the problem for today. I am working on a larger article  with all the goodies about Ajax usability and accessibility.</p>
<p>However, to make this more re-usable we could do the following:</p>
<pre><code>$(document).ready(function(){
$('.ajaxtrigger').click(function(){
$('#target').load($(this).attr('href'));
return false;
});
});</code></pre>
<p>You can then use <code>&lt;a href="ajaxcontent.html"&gt;load some content&lt;/a&gt;</code> to load the content and you make the whole thing re-usable.</p>
<p>Check out this <a href="http://icant.co.uk/articles/crossdomain-ajax-with-jquery/reusable-ajax.html">more reusable Ajax demo</a> to see what it does.</p>
<p>The issue I wanted to find a nice solution for is the one that  happens when you click on the second link in the demo: loading external  files fails as Ajax doesn’t allow for cross-domain loading of content.  This means that <code>&lt;a href="http://icant.co.uk/"&gt;see my portfolio&lt;/a&gt;</code> will fail to load the Ajax content and fail silently at that. You can  click the link until you are blue in the face but nothing happens. A  dirty hack to avoid this is just allowing the browser to load the  document if somebody really tries to load an external link.</p>
<p>Check out this <a href="http://icant.co.uk/articles/crossdomain-ajax-with-jquery/allowing-link-following.html">allowing external links to be followed</a> to see what it does.</p>
<pre><code>$(document).ready(function(){
$('.ajaxtrigger').click(function(){
var url = $(this).attr('href');
if(url.match('^http')){
return true;
} else {
$('#target').load(url);
return false;
}
});
});</code></pre>
<h2>Proxying with PHP</h2>
<p>If you look around the web you will find the solution in most of the cases to be PHP proxy scripts (or any other language). Something <a href="http://www.wait-till-i.com/2009/12/18/curl-your-view-source-of-the-web">using cURL</a> could be for example <code>proxy.php</code>:</p>
<pre><code>&lt;?php
$url = $_GET['url'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
echo $content;
?&gt;</code></pre>
<p>People then could use this with a slightly changed script (<a href="http://icant.co.uk/articles/crossdomain-ajax-with-jquery/using-proxy.html">using a proxy</a>):</p>
<pre><code>$(document).ready(function(){
$('.ajaxtrigger').click(function(){
var url = $(this).attr('href');
if(url.match('^http')){
url = 'proxy.php?url=' + url;
}
$('#target').load(url);
return false;
});
});</code></pre>
<p>It is also a <strong>spectacularly stupid idea</strong> to have a  proxy script like that. The reason is that without filtering people can  use this to load any document of your server and display it in the page  (simply use firebug to rename the link to show anything on your server),  they can use it to inject a mass-mailer script into your document or  simply use this to redirect to any other web resource and make it look  like your server was the one that sent it. It is spammer’s heaven.</p>
<h2>Use a white-listing and filtering proxy!</h2>
<p>So if you want to use a proxy, make sure to white-list the allowed  URIs. Furthermore it is a good plan to get rid of everything but the  body of the other HTML document. Another good  idea is to filter out scripts. This prevents display glitches and  scripts you don’t want executed on your site to get executed.</p>
<p>Something like this:</p>
<pre><code>&lt;?php
$url = $_GET['url'];
$allowedurls = array(
'http://developer.yahoo.com',
'http://icant.co.uk'
);
if(in_array($url,$allowedurls)){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$content = preg_replace('/.*&lt;body[^&gt;]*&gt;/msi','',$output);
$content = preg_replace('/&lt;/body&gt;.*/msi','',$content);
$content = preg_replace('/&lt;?/body[^&gt;]*&gt;/msi','',$content);
$content = preg_replace('/[r|n]+/msi','',$content);
$content = preg_replace('/&lt;--[Ss]*?--&gt;/msi','',$content);
$content = preg_replace('/&lt;noscript[^&gt;]*&gt;[Ss]*?&lt;/noscript&gt;/msi',
'',$content);
$content = preg_replace('/&lt;script[^&gt;]*&gt;[Ss]*?&lt;/script&gt;/msi',
'',$content);
$content = preg_replace('/&lt;script.*/&gt;/msi','',$content);
echo $content;
} else {
echo 'Error: URL not allowed to load here.';
}
?&gt;</code></pre>
<h2>Pure JavaScript solution using YQL</h2>
<p>But what if you have no server access or you want to stay in JavaScript? Not to worry – it can be done. <a href="http://developer.yahoo.com/yql">YQL</a> allows you to load any HTML document and get it back in JSON. As jQuery has a nice interface to load JSON, this can be used together to achieve what we want to.</p>
<p>Getting HTML from YQL is as easy as using:</p>
<pre><code>select * from html where url="http://icant.co.uk"</code></pre>
<p>YQL does a few things extra for us:</p>
<ul>
<li>It loads the HTML document and sanitizes it</li>
<li>It runs the HTML document through HTML Tidy to remove things <del>.NET</del><ins>nasty frameworks</ins> considered markup.</li>
<li>It caches the HTML for a while</li>
<li>It only returns the body content of the HTML &#8211; so no styling (other than inline styles) will get through.</li>
</ul>
<p>As output formats you can choose XML or JSON. If you define a callback parameter for JSON you get JSON-P with all the HTML as a JavaScript Object – not fun to re-assemble:</p>
<pre><code>foo({
"query":{
&lt;a href=""1" title=""&gt;count&lt;/a&gt;",
&lt;a href=""2010-01-10T07:51:43Z" title=""&gt;created&lt;/a&gt;",
&lt;a href=""en-US" title=""&gt;lang&lt;/a&gt;",
&lt;a href=""2010-01-10T07:51:43Z" title=""&gt;updated&lt;/a&gt;",
&lt;a href=""http://query.yahoo[...whatever...]k%22" title=""&gt;uri&lt;/a&gt;",
"results":{
"body":{
"div":{
&lt;a href=""doc2" title=""&gt;id&lt;/a&gt;",
&lt;a href="[{"id":"hd" title=""&gt;div&lt;/a&gt;",
&lt;a href=""icant.co.uk" title=""&gt;h1&lt;/a&gt; - everything Christian Heilmann"
},
{&lt;a href=""bd" title=""&gt;id&lt;/a&gt;",
"div":[
{&lt;a href="[{"h2":"About" title=""&gt;div&lt;/a&gt; this and me","[... and so on...]
}}}}}}}});</code></pre>
<p>When you define a callback with the XML output you get a function call with the HTML data as string in an Array – much easier:</p>
<pre><code>foo({
"query":{
&lt;a href=""1" title=""&gt;count&lt;/a&gt;",
&lt;a href=""2010-01-10T07:47:40Z" title=""&gt;created&lt;/a&gt;",
&lt;a href=""en-US" title=""&gt;lang&lt;/a&gt;",
&lt;a href=""2010-01-10T07:47:40Z" title=""&gt;updated&lt;/a&gt;",
&lt;a href=""http://query.y[...who" title=""&gt;uri&lt;/a&gt; cares...]%22"},
"results":[
"&lt;body&gt;n    &lt;div id="doc2"&gt;n      &lt;div id="hd"&gt;n
&lt;h1&gt;icant.co.uk - everything Christian Heilmann&lt;/h1&gt;n
... and so on ..."
]
});</code></pre>
<p>Using jQuery’s <code>getJSON()</code> method and accessing the YQL endpoint this is easy to implement:</p>
<pre><code>$.getJSON("http://query.yahooapis.com/v1/public/yql?"+
"q=select%20*%20from%20html%20where%20url%3D%22"+
encodeURIComponent(url)+
"%22&amp;format=xml'&amp;callback=?",
function(data){
if(data.results[0]){
var data = filterData(data.results[0]);
container.html(data);
} else {
var errormsg = '&lt;p&gt;Error: could not load the page.&lt;/p&gt;';
container.html(errormsg);
}
}
);</code></pre>
<p>Putting it all together you have a <a href="http://icant.co.uk/articles/crossdomain-ajax-with-jquery/using-yql.html">cross-domain Ajax solution with jQuery and YQL</a>:</p>
<pre><code>$(document).ready(function(){
var container = $('#target');
$('.ajaxtrigger').click(function(){
doAjax($(this).attr('href'));
return false;
});
function doAjax(url){
// if it is an external URI
if(url.match('^http')){
// call YQL
$.getJSON("http://query.yahooapis.com/v1/public/yql?"+
"q=select%20*%20from%20html%20where%20url%3D%22"+
encodeURIComponent(url)+
"%22&amp;format=xml'&amp;callback=?",
// this function gets the data from the successful
// JSON-P call
function(data){
// if there is data, filter it and render it out
if(data.results[0]){
var data = filterData(data.results[0]);
container.html(data);
// otherwise tell the world that something went wrong
} else {
var errormsg = '&lt;p&gt;Error: could not load the page.&lt;/p&gt;';
container.html(errormsg);
}
}
);
// if it is not an external URI, use Ajax load()
} else {
$('#target').load(url);
}
}
// filter out some nasties
function filterData(data){
data = data.replace(/&lt;?/body[^&gt;]*&gt;/g,'');
data = data.replace(/[r|n]+/g,'');
data = data.replace(/&lt;--[Ss]*?--&gt;/g,'');
data = data.replace(/&lt;noscript[^&gt;]*&gt;[Ss]*?&lt;/noscript&gt;/g,'');
data = data.replace(/&lt;script[^&gt;]*&gt;[Ss]*?&lt;/script&gt;/g,'');
data = data.replace(/&lt;script.*/&gt;/,'');
return data;
}
});</code></pre>
<p>This is rough and ready of course. A real Ajax solution should also consider timeout and not found scenarios. Check out the <a href="http://icant.co.uk/articles/crossdomain-ajax-with-jquery/error-handling.html">full version with loading indicators, error handling and yellow fade</a> for inspiration.</p>
<p>you can find original post here : <a href="http://www.wait-till-i.com/2010/01/10/loading-external-content-with-ajax-using-jquery-and-yql/" target="_blank">http://www.wait-till-i.com/2010/01/10/loading-external-content-with-ajax-using-jquery-and-yql/</a></p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.amphee.com/index.php/2010/11/15/loading-external-content-with-ajax-using-jquery-and-yql/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	
	
	<!-- google ad injected by adsense-optimizer http://www.adsenseoptimizer.de -->
	<div  style="padding:3px; display: block; margin-left: auto; margin-right: auto; text-align: center;"><!-- Ad number: 3 --><script type="text/javascript"><!--
    	 
    	google_ad_client = "pub-0687753067406098"; google_alternate_color = "FFFFFF";
		google_ad_width = 468; google_ad_height = 60;
		google_ad_format = "468x60_as"; google_ad_type = "text_image";
		google_ad_channel =""; google_color_border = "A6C9E2";
		google_color_link = "FF3019"; google_color_bg = "FFFFFF";
		google_color_text = "000000"; google_color_url = "7EB544";
		google_ui_features = "rc:0"; //--></script>
		<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div>	<item>
		<title>Using jQuery to post an array to a ColdFusion Component</title>
		<link>http://blog.amphee.com/index.php/2010/11/15/using-jquery-to-post-an-array-to-a-coldfusion-component/</link>
		<comments>http://blog.amphee.com/index.php/2010/11/15/using-jquery-to-post-an-array-to-a-coldfusion-component/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 06:13:57 +0000</pubDate>
		<dc:creator>kiran vadariya</dc:creator>
				<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery and array component]]></category>
		<category><![CDATA[jquery blog post]]></category>

		<guid isPermaLink="false">http://blog.amphee.com/?p=319</guid>
		<description><![CDATA[A reader sent in an interesting question today. He was trying to make  use of jQuery to post an array of data to a ColdFusion component. His  CFC was expecting, and demanding, an array argument. Whenever he fired  off the request though he received an error from ColdFusion saying the  argument [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>A reader sent in an interesting question today. He was trying to make  use of jQuery to post an array of data to a ColdFusion component. His  CFC was expecting, and demanding, an array argument. Whenever he fired  off the request though he received an error from ColdFusion saying the  argument was not a valid array. Let&#8217;s look at an example of this so it  is more clear.</p>
<p>I&#8217;ll start off with my server side component. It handles the incredibly complex task of returning the size of an array.</p>
<div>
<div><a id="view_EB31BF63D711D2793790F8CCE2EBAC6A">view plain</a><a id="view_copy_to_clipboard_link_EB31BF63D711D2793790F8CCE2EBAC6A">copy to clipboard</a><a>print</a><a>about</a></div>
<p>ColdFISH is developed by Jason Delmore.  Source code and license information available at <a href="http://coldfish.riaforge.org/">coldfish.riaforge.org</a></p>
<pre>&lt;cfcomponent&gt;

&lt;cffunction name="handleArray" access="remote" returnType="numeric"&gt;
	&lt;cfargument name="data" type="array" required="true"&gt;
	&lt;cfreturn arrayLen(arguments.data)&gt;
&lt;/cffunction&gt;

&lt;/cfcomponent&gt;</pre>
<p>1  &lt;cfcomponent&gt;<br />
2<br />
3  &lt;cffunction name=&#8221;handleArray&#8221; access=&#8221;remote&#8221; returnType=&#8221;numeric&#8221;&gt;<br />
4      &lt;cfargument name=&#8221;data&#8221; type=&#8221;array&#8221; required=&#8221;true&#8221;&gt;<br />
5      &lt;cfreturn arrayLen(arguments.data)&gt;<br />
6  &lt;/cffunction&gt;<br />
7<br />
8  &lt;/cfcomponent&gt;</p>
</div>
<p>On the client side, I&#8217;m going to use jQuery to post a static query to  the CFC. This will happen immediately on document load so I don&#8217;t have  to bother clicking a button or anything fancy like that. (Note, in the  code block below I&#8217;ve removed the html, head, and body tags since they  are all empty. I do have a script block to load in the jQuery library  though.)</p>
<div>
<div><a id="view_8240F2C118B426532DB595D08926D514">view plain</a><a id="view_copy_to_clipboard_link_8240F2C118B426532DB595D08926D514">copy to clipboard</a><a>print</a><a>about</a></div>
<p>ColdFISH is developed by Jason Delmore.  Source code and license information available at <a href="http://coldfish.riaforge.org/">coldfish.riaforge.org</a></p>
<pre>$(document).ready(function() {
	var mydata = [1,2,3,4,5,"Camden,Raymond"];
	$.post("test.cfc", {method:"handleArray",data:mydata, returnFormat:"plain"}, function(res) {
		alert($.trim(res));
	})

})</pre>
<p>1  $(document).ready(function() {<br />
2      var mydata = [1,2,3,4,5,"Camden,Raymond"];<br />
3      $.post(&#8220;test.cfc&#8221;, {method:&#8221;handleArray&#8221;,data:mydata, returnFormat:&#8221;plain&#8221;}, function(res) {<br />
4          alert($.trim(res));<br />
5      })<br />
6<br />
7  })</p>
</div>
<p>So, what would you expect to happen here? Well first off, it is  important to remember that we are talking about an HTTP post here. You <em>cannot</em> send a complex data type of POST. It <em>must</em> be encoded somehow. jQuery does indeed encode the data &#8211; just not how  you would expect it. Upon running this and examining the POST data in my  Chrome dev tools, I see the following:</p>
<p><a href="http://www.coldfusionjedi.com/images/Screen%20shot%202010-03-23%20at%202.39.13%20PM.png"><img class="alignleft" title="img" src="http://www.coldfusionjedi.com/images/Screen%20shot%202010-03-23%20at%202.39.13%20PM.png" alt="" width="225" height="145" /></a></p>
<p>Not what you expected, right? You can see why ColdFusion complained. The  &#8220;Data&#8221; argument doesn&#8217;t exist. Instead we have a lit of things named  like Data, but not quite. You can try using toString on the array, but  that doesn&#8217;t correctly handle the comma in the data. So what to do?</p>
<p>What I recommended was converting the array to JSON. It always surprises  me when I remember that jQuery can&#8217;t produce JSON on its own, but there  are <a href="http://code.google.com/p/jquery-json/">plugins</a> out  there that will do it it for you. Because JSON is a string format though  I thought I&#8217;d write up a quick function to generate the string for me.  This function makes the assumption that are array only contains simple  values of numbers and strings.</p>
<div>
<div><a id="view_3607E4665B9B0C1B30E8ACCAA419079F">view plain</a><a id="view_copy_to_clipboard_link_3607E4665B9B0C1B30E8ACCAA419079F">copy to clipboard</a><a>print</a><a>about</a></div>
<p>ColdFISH is developed by Jason Delmore.  Source code and license information available at <a href="http://coldfish.riaforge.org/">coldfish.riaforge.org</a></p>
<pre>$(document).ready(function() {
	var mydata = [1,2,3,4,5,"Camden,Raymond"];
	var myds = serialize(mydata)
	$.post("test.cfc", {method:"handleArray",data:mydata, returnFormat:"plain"}, function(res) {
		alert($.trim(res));
	})

	function serialize(arr) {
		var s = "[";
		for(var i=0; i&lt;arr.length; i++) {
			if(typeof(arr[i]) == "string") s += '"' + arr[i] + '"'
			else s += arr[i]
			if(i+1 &lt; arr.length) s += ","
		}
		s += "]"
		return s
	}
})</pre>
<p>1  $(document).ready(function() {<br />
2      var mydata = [1,2,3,4,5,"Camden,Raymond"];<br />
3      var myds = serialize(mydata)<br />
4      $.post(&#8220;test.cfc&#8221;, {method:&#8221;handleArray&#8221;,data:mydata, returnFormat:&#8221;plain&#8221;}, function(res) {<br />
5          alert($.trim(res));<br />
6      })<br />
7<br />
8      function serialize(arr) {<br />
9          var s = &#8220;[";<br />
10          for(var i=0; i&lt;arr.length; i++) {<br />
11              if(typeof(arr[i]) == &#8220;string&#8221;) s += &#8216;&#8221;&#8216; + arr[i] + &#8216;&#8221;&#8216;<br />
12              else s += arr[i]<br />
13              if(i+1 &lt; arr.length) s += &#8220;,&#8221;<br />
14          }<br />
15          s += &#8220;]&#8221;<br />
16          return s<br />
17      }<br />
18  })</p>
</div>
<p>As you can see, I wrote a serialize function to handle converting the  array into a JSON-encoded array. This isn&#8217;t the only change though. We  still aren&#8217;t sending an array to the CFC. It&#8217;s a string. So I rewrote  the CFC to handle it a bit better:</p>
<div>
<div><a id="view_4545E2329ED13EEA0308813233A3CC5D">view plain</a><a id="view_copy_to_clipboard_link_4545E2329ED13EEA0308813233A3CC5D">copy to clipboard</a><a>print</a><a>about</a></div>
<p>ColdFISH is developed by Jason Delmore.  Source code and license information available at <a href="http://coldfish.riaforge.org/">coldfish.riaforge.org</a></p>
<pre>&lt;cfcomponent&gt;

&lt;cffunction name="handleArray" access="remote" returnType="numeric"&gt;
	&lt;cfargument name="data" type="any" required="true"&gt;
	&lt;cfif isJSON(arguments.data)&gt;
		&lt;cfset arguments.data  = deserializeJSON(arguments.data)&gt;
	&lt;/cfif&gt;
	&lt;cfreturn arrayLen(arguments.data)&gt;
&lt;/cffunction&gt;

&lt;/cfcomponent&gt;</pre>
<p>1  &lt;cfcomponent&gt;<br />
2<br />
3  &lt;cffunction name=&#8221;handleArray&#8221; access=&#8221;remote&#8221; returnType=&#8221;numeric&#8221;&gt;<br />
4      &lt;cfargument name=&#8221;data&#8221; type=&#8221;any&#8221; required=&#8221;true&#8221;&gt;<br />
5      &lt;cfif isJSON(arguments.data)&gt;<br />
6          &lt;cfset arguments.data  = deserializeJSON(arguments.data)&gt;<br />
7      &lt;/cfif&gt;<br />
8      &lt;cfreturn arrayLen(arguments.data)&gt;<br />
9  &lt;/cffunction&gt;<br />
10<br />
11  &lt;/cfcomponent&gt;</p>
</div>
<p>I normally don&#8217;t like to &#8220;muck&#8221; up my code so that it has outside  knowledge like this. However, I&#8217;d probably have a remote service  component in front of this component anyway and the whole issue would  become moot.</p>
<p>There are probably <em>many</em> better ways of handling this. Any suggestions?</p>
<p>you can find original post here : <a href="http://www.coldfusionjedi.com/index.cfm/2010/3/23/Using-jQuery-to-post-an-array-to-a-ColdFusion-Component" target="_blank">http://www.coldfusionjedi.com/index.cfm/2010/3/23/Using-jQuery-to-post-an-array-to-a-ColdFusion-Component</a></p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.amphee.com/index.php/2010/11/15/using-jquery-to-post-an-array-to-a-coldfusion-component/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How CSS and JavaScript Are Different</title>
		<link>http://blog.amphee.com/index.php/2010/11/15/how-css-and-javascript-are-different/</link>
		<comments>http://blog.amphee.com/index.php/2010/11/15/how-css-and-javascript-are-different/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 06:06:47 +0000</pubDate>
		<dc:creator>kiran vadariya</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[css blog]]></category>
		<category><![CDATA[css javascript]]></category>
		<category><![CDATA[difference of css and javascript]]></category>

		<guid isPermaLink="false">http://blog.amphee.com/?p=315</guid>
		<description><![CDATA[So, what&#8217;s this important difference?
In CSS, style rules are automatically applied to any element that matches the selectors, no matter when those elements are added to the document (DOM).
In JavaScript, event handlers that are registered for elements in the document apply only to those elements that are part of the DOM at the time the [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>So, what&#8217;s this important difference?</p>
<p><strong>In <abbr title="Cascading Style Sheets">CSS</abbr></strong>, style rules are automatically applied to any element that matches the selectors, <em>no matter when those elements are added to the document (DOM)</em>.</p>
<p><strong>In JavaScript</strong>, event handlers that are registered for elements in the document apply <em>only to those elements that are part of the DOM at the time the event is attached</em>.  If we add similar elements to the DOM at a later time, whether through  simple DOM manipulation or ajax, CSS will give those elements the same  appearance, but JavaScript will not automatically make them act the same  way.<br />
<button class="alert">Alert!</button></p>
<p>For example, let&#8217;s say we have &#8220;<code>&lt;button&gt;Alert!&lt;/button&gt;</code>&#8221;  in our document, and we want to attach a click handler to it that  generates an alert message. In jQuery, we might do so with the following  code:</p>
<div><a href="http://www.learningjquery.com/2008/03/working-with-events-part-1#">PLAIN TEXT</a></div>
<div>
<p>JavaScript:</p>
<div id="javascript-1">
<div>
<ol>
<li>
<div>$(document).<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=ready">ready</a>(function() {</div>
</li>
<li>
<div>$(&#8216;button.alert&#8217;).<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=click">click</a>(function() {</div>
</li>
<li>
<div>alert(&#8216;this is an alert message&#8217;);</div>
</li>
<li>
<div>});</div>
</li>
<li>
<div>});</div>
</li>
</ol>
</div>
</div>
</div>
<p>Here we are registering the click handler for the button with a class  of &#8220;alert&#8221; as soon as the DOM has loaded. So, the button is there, and  we have a click function bound to it. If we add a second <code>&lt;button&gt;</code> later on, however, it will know nothing about that click handler. The  click event had been dealt with before this second button existed. So,  the second button will not generate an alert.</p>
<p>Let&#8217;s test what we&#8217;ve just discussed. I&#8217;ve added a script with the  above three lines of jQuery code so that the following button will  produce an alert message when clicked. Try it:</p>
<p><button class="alert">Alert!</button></p>
<h4>Events Don&#8217;t Work with Added Elements</h4>
<p>Now, let&#8217;s create a new button (if we don&#8217;t already have a second one) using jQuery code like this:</p>
<div><a href="http://www.learningjquery.com/2008/03/working-with-events-part-1#">PLAIN TEXT</a></div>
<div>
<p>JavaScript:</p>
<div id="javascript-2">
<div>
<ol>
<li>
<div>$(&#8216;#create-button&#8217;).<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=click">click</a>(function() {</div>
</li>
<li>
<div>if ( $(&#8216;button.alert&#8217;).<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=length">length</a> &lt;2) {</div>
</li>
<li>
<div>$(&#8216;&lt;button&gt;Not another alert&#8217;).<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=insertAfter">insertAfter</a>(this);</div>
</li>
<li>
<div>}</div>
</li>
<li>
<div>return false;</div>
</li>
<li>
<div>});</div>
</li>
</ol>
</div>
</div>
</div>
<p><a id="create-button" href="http://www.learningjquery.com/2008/03/working-with-events-part-1#">create the button</a></p>
<p>Have you clicked the link to create the second button? Great. Now click that button. It does nothing. Just as expected.</p>
<h4>CSS Continues to &#8220;Work&#8221; with Newly Created Elements</h4>
<p>Now let&#8217;s take a look at another example. In this one, we have three list items—two plain items and one with a class of special:</p>
<div><a href="http://www.learningjquery.com/2008/03/working-with-events-part-1#">PLAIN TEXT</a></div>
<div>
<p>HTML:</p>
<div id="html-3">
<div>
<ol>
<li>
<div>&lt;ul id=&#8221;list1&#8243; class=&#8221;eventlist&#8221;&gt;</div>
</li>
<li>
<div>&lt;li&gt;plain&lt;/li&gt;</div>
</li>
<li>
<div>&lt;li class=&#8221;special&#8221;&gt;special &lt;button&gt;I am special&lt;/button&gt;&lt;/li&gt;</div>
</li>
<li>
<div>&lt;li&gt;plain&lt;/li&gt;</div>
</li>
<li>
<div>&lt;/ul&gt;</div>
</li>
</ol>
</div>
</div>
</div>
<p>Press the &#8220;I am special&#8221; button to create a <em>new</em> list item with a class of &#8220;special&#8221;:</p>
<ul id="list1">
<li>plain</li>
<li>special <button>I am special</button></li>
<li>plain</li>
</ul>
<p>Notice that, like the first special li, the new one has the yellow  background. The CSS has come through for us. But press the newly created  &#8220;I am new&#8221; button and, just as with the second alert above, nothing  happens. The jQuery code we&#8217;re using to add the new item says that upon  clicking a button inside a list item with a class of &#8220;special&#8221; (which  itself is inside an element with id of &#8220;list1&#8243;) a new list item with  class=&#8221;special&#8221; should be inserted after the list item in which the  button was clicked:</p>
<div><a href="http://www.learningjquery.com/2008/03/working-with-events-part-1#">PLAIN TEXT</a></div>
<div>
<p>JavaScript:</p>
<div id="javascript-4">
<div>
<ol>
<li>
<div>$(document).<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=ready">ready</a>(function() {</div>
</li>
<li>
<div>$(&#8216;#list1 li.special button&#8217;).<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=click">click</a>(function() {</div>
</li>
<li>
<div>var $newLi = $(&#8216;&lt;li&gt;special and new &lt;button&gt;I am new&lt;/button&gt;&lt;/li&gt;&#8217;);</div>
</li>
<li>
<div>$(this).<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=parent">parent</a>().<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=after">after</a>($newLi);</div>
</li>
<li>
<div>});</div>
</li>
<li>
<div>});</div>
</li>
</ol>
</div>
</div>
</div>
<p>So, how can we get the events to carry over to the new elements? Two common approaches are <strong>event delegation</strong> and <strong>&#8220;re-binding&#8221; event handlers</strong>. In this entry, we&#8217;ll examine event delegation; in part 2, we&#8217;ll explore ways to re-bind.</p>
<h4>Event Delegation: Getting Events to Embrace New Elements</h4>
<p>The general idea of event delegation is to bind the event handler to a  containing element and then have an action take place based on which  specific element within that containing element is targeted. Let&#8217;s say  we have another unordered list: <code>&lt;ul id="list2"&gt; ... &lt;/ul&gt;</code>. Instead of attaching the <code>.click()</code> method to a button — <code>$('#list2 li.special button').click(...)</code> — we can attach it to the entire surrounding <code>&lt;ul&gt;</code>. Through the magic of &#8220;<a href="http://www.quirksmode.org/js/events_order.html">bubbling</a>,&#8221;  any click on the button is also a click on the button&#8217;s surrounding  list item, the list as a whole, the containing div, and all the way up  to the window object. Since the <code>&lt;ul&gt;</code> that gets clicked is the same one each time (we&#8217;re only creating items <em>within</em> the <code>&lt;ul&gt;</code>), the same thing will happen when clicking on all of the buttons, regardless of when they were created.</p>
<p>When we use event delegation, we need to pass in the &#8220;event&#8221; argument. So, in our case, instead of <code>.click()</code>, we&#8217;ll have <code>.click(event)</code>. We don&#8217;t have to name this argument <code>event</code>. We can call it <code>e</code> or <code>evt</code> or <code>gummy</code> or whatever we want. I just like to use labels that are as obvious as  possible because I have a hard time keeping track of things. Here is  what we have so far:</p>
<div><a href="http://www.learningjquery.com/2008/03/working-with-events-part-1#">PLAIN TEXT</a></div>
<div>
<p>JavaScript:</p>
<div id="javascript-5">
<div>
<ol>
<li>
<div>$(document).<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=ready">ready</a>(function() {</div>
</li>
<li>
<div>$(&#8216;#list2&#8242;).<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=click">click</a>(function(event) {</div>
</li>
<li>
<div>var $newLi = $(&#8216;&lt;li&gt;special and new &lt;button&gt;I am new&lt;/button&gt;&lt;/li&gt;&#8217;);</div>
</li>
<li>
<div>});</div>
</li>
<li>
<div>});</div>
</li>
</ol>
</div>
</div>
</div>
<p>So far, the code is very similar to our first attempt, except for the  selector we&#8217;re starting with (#list2) and the addition of the event  argument. Now we need to determine whether what is being clicked inside  the <code>&lt;ul&gt;</code> is a &#8220;special&#8221; button or not. If it is, we can add a new <code>&lt;li&gt;</code>. We check the clicked element by using the &#8220;target&#8221; property of the event argument:</p>
<div><a href="http://www.learningjquery.com/2008/03/working-with-events-part-1#">PLAIN TEXT</a></div>
<div>
<p>JavaScript:</p>
<div id="javascript-6">
<div>
<ol>
<li>
<div>$(document).<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=ready">ready</a>(function() {</div>
</li>
<li>
<div>$(&#8216;#list2&#8242;).<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=click">click</a>(function(event) {</div>
</li>
<li>
<div>var $newLi = $(&#8216;&lt;li&gt;special and new &lt;button&gt;I am new&lt;/button&gt;&lt;/li&gt;&#8217;);</div>
</li>
<li>
<div>var $tgt = $(event.target);</div>
</li>
<li>
<div>if ($tgt.is(&#8216;button&#8217;)) {</div>
</li>
<li>
<div>$tgt.<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=parent">parent</a>().<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=after">after</a>($newLi);</div>
</li>
<li>
<div>}</div>
</li>
<li>
<div>// next 2 lines show that you&#8217;ve clicked on the ul</div>
</li>
<li>
<div>var bgc = $(this).<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=css">css</a>(&#8216;backgroundColor&#8217;);</div>
</li>
<li>
<div>$(this).<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=css">css</a>({backgroundColor: bgc == &#8216;#ffcccc&#8217; || bgc == &#8216;rgb(255, 204, 204)&#8217; ? &#8216;#ccccff&#8217; : &#8216;#ffcccc&#8217;});</div>
</li>
<li>
<div>});</div>
</li>
<li>
<div>});</div>
</li>
</ol>
</div>
</div>
</div>
<p>Line 4 above puts the target element in a jQuery wrapper and stores  it in the $tgt variable. Line 5 checks whether the click&#8217;s target is a  button. If it is, the new list item is inserted after the parent of the  clicked button. Let&#8217;s try it:</p>
<ul id="list2">
<li>plain</li>
<li>special <button>I am special</button></li>
<li>plain</li>
</ul>
<p>I put an additional two lines at the end to demonstrate that a click on one of the buttons is still considered a click on the <code>&lt;ul&gt;</code> You&#8217;ll see that clicking anywhere within the <code>&lt;ul&gt;</code> toggles its background between pink and blue.</p>
<p>It&#8217;s probably worth noting that jQuery makes working with the event  argument cross-browser friendly. If you do this sort of thing with plain  JavaScript and DOM nodes, you&#8217;d have to do something like this:</p>
<pre><code>var list2 = document.getElementById('list2');
list2.onclick = function(e) {
  var e = e || window.event;
  var tgt = e.target || e.srcElement;
  if (tgt.nodeName.toLowerCase() == 'button') {
    // do something
  }
};</code></pre>
<p>As you can see, it&#8217;s a bit of a hassle.</p>
<h4>Another Huge Benefit of Event Delegation</h4>
<p>Event delegation is also a great way to avoid crippling the user&#8217;s  browser when you&#8217;re working with a huge document. For example, if you  have a table with thousands of cells, and you want something to happen  when the user clicks on one, you won&#8217;t want to attach a click handler to  every single one of them (believe me, it can get ugly). Instead, you  can attach the click handler to a single table element and use <code>event.target</code> to pinpoint the cell that is being clicked:</p>
<div><a href="http://www.learningjquery.com/2008/03/working-with-events-part-1#">PLAIN TEXT</a></div>
<div>
<p>JavaScript:</p>
<div id="javascript-7">
<div>
<ol>
<li>
<div>$(document).<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=ready">ready</a>(function() {</div>
</li>
<li>
<div>$(&#8216;table&#8217;).<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=click">click</a>(function(event) {</div>
</li>
<li>
<div>var $thisCell, $tgt = $(event.target);</div>
</li>
<li>
<div>if ($tgt.is(&#8216;td&#8217;)) {</div>
</li>
<li>
<div>$thisCell = $tgt;</div>
</li>
<li>
<div>} else if ($tgt.<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=parents">parents</a>(&#8216;td&#8217;).<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=length">length</a>) {</div>
</li>
<li>
<div>$thisCell = $tgt.<a href="http://www.learningjquery.com/wp-content/themes/ljq/docs.php?fn=parents">parents</a>(&#8216;td:first&#8217;);</div>
</li>
<li>
<div>}</div>
</li>
<li>
<div>// now do something with $thisCell</div>
</li>
<li>
<div>});</div>
</li>
<li>
<div>});</div>
</li>
</ol>
</div>
</div>
</div>
<p>Note that I had to account for the possibility of clicking in a  child/descendant of a table cell, but this seems a small inconvenience  for the great performance increase that event delegation affords.</p>
<p>you can find original post here : <a href="http://www.learningjquery.com/2008/03/working-with-events-part-1#" target="_blank">http://www.learningjquery.com/2008/03/working-with-events-part-1#</a></p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.amphee.com/index.php/2010/11/15/how-css-and-javascript-are-different/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How To: AJAX Post Pagination in MooTools</title>
		<link>http://blog.amphee.com/index.php/2010/11/15/how-to-ajax-post-pagination-in-mootools/</link>
		<comments>http://blog.amphee.com/index.php/2010/11/15/how-to-ajax-post-pagination-in-mootools/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 06:00:03 +0000</pubDate>
		<dc:creator>kiran vadariya</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[ajax blog]]></category>
		<category><![CDATA[ajax pagination in MooTools]]></category>
		<category><![CDATA[ajax post]]></category>

		<guid isPermaLink="false">http://blog.amphee.com/?p=313</guid>
		<description><![CDATA[Ever wanted to browse through the older post archives only to be  staring at the screen for ages in frustration while the content slowly  loads up? A quick fix would be to make use of AJAX to load the post archives. In this tutorial, I will show you how to do that using [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Ever wanted to browse through the older post archives only to be  staring at the screen for ages in frustration while the content slowly  loads up? A quick fix would be to <strong>make use of AJAX to load the post archives</strong>. In this tutorial, I will show you how to do that using the ever popular JavaScript framework; <a title="Compact JavaScript framework" href="http://mootools.net/">MooTools</a> on a typical 2 column WordPress theme.</p>
<p>The code is quite easily digestible and with a little CSS tweaking, you could get it to work for your theme.</p>
<h2>Step 1: Readying the Files</h2>
<p>Download the file <a title="MooTools core 1.2.2" href="http://www.problogdesign.com/wp-content/uploads/2009/05/mootools_core.js">mootools_core.js</a> and upload it into a folder within the directory of your active WordPress theme and name it as <strong>js</strong>.</p>
<p>I only included components needed for AJAX post pagination in this  MooTools build. You are however welcome to create a new one with  components you would like to use.</p>
<p>Create a <strong>blank JavaScript file called ajax.js</strong> and upload into the js folder. At this point of time, you should have these 2 files in your js folder.</p>
<p><em>yoursite.com/wp-content/themes/yourtheme/js/mootools_core.js</em><br />
<em>yoursite.com/wp-content/themes/yourtheme/js/ajax.js</em></p>
<h2>Step 2: Edit header.php</h2>
<p>You have to tell the browser that we have a JavaScript file to use.  Add the following lines into your header.php just before the closing  &lt;/head&gt; tag.</p>
<div>
<div>
<pre>&lt;?php wp_enqueue_script('mootools', '/wp-content/themes/yourtheme/js/mootools_core.js')); ?&gt;
&lt;?php wp_enqueue_script('mootools_ajax', '/wp-content/themes/yourtheme/js/ajax.js')); ?&gt;</pre>
</div>
</div>
<p>Where <em>yourtheme</em> is the folder <strong>name of your active theme</strong>.</p>
<h2>Step 3: Edit index.php</h2>
<p>When it comes to AJAX pagination, we only want to <strong>refresh the post listings</strong> and not other portions of your site. The following code snippets will tell the browser to skip loading the entire page.</p>
<p>The top of your index.php file should have the following line:</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1</pre>
</td>
<td>
<pre>&lt;?php get_header(); ?&gt;</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>Replace that line with this:</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3</pre>
</td>
<td>
<pre>&lt;?php if (!isset($_GET['ajax'])) { ?&gt;
&lt;?php get_header(); ?&gt;
&lt;?php } ?&gt;</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>Similarly, at the very end of the file you should see:</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2</pre>
</td>
<td>
<pre>&lt;?php get_sidebar(); ?&gt;
&lt;?php get_footer(); ?&gt;</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>Now replace it with this:</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4</pre>
</td>
<td>
<pre>&lt;?php if (!isset($_GET['ajax'])) { ?&gt;
&lt;?php get_sidebar(); ?&gt;
&lt;?php get_footer(); ?&gt;
&lt;?php } ?&gt;</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>To avoid any possible causes for the code not to work, <strong>do ensure that your HTML structure is identical to the ones listed</strong> below. We will need to have a div with an id of ‘post’ nesting <a title="used by WordPress to display each of your posts" href="http://codex.wordpress.org/The_Loop">the loop</a>.</p>
<p>Go back into index.php and add the div before the start of the loop, i.e. the end result should look like this:</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2</pre>
</td>
<td>
<pre>&lt;div id="post"&gt;
&lt;?php if (have_posts()) { ?&gt;</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>Be sure to also close the &lt;div&gt; after the loop ends.</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2</pre>
</td>
<td>
<pre>&lt;?php } ?&gt;
&lt;/div&gt;</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>We also need a div with a CSS class of ‘page-navi’ to nest the post pagination links.</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4</pre>
</td>
<td>
<pre>&lt;div class="page-navi"&gt;
	&lt;?php next_posts_link('- Older Posts -') ?&gt;
	&lt;?php previous_posts_link('- Newer Posts -') ?&gt;
&lt;/div&gt;</pre>
</td>
</tr>
</tbody>
</table>
</div>
<h2>Step 4: Writing your ajax.js</h2>
<p>This is basically what goes on in your JavaScript file. I have left  some pretty detailed comments so that you know what the code is all  about.</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40</pre>
</td>
<td>
<pre>//function used to handle AJAX post pagination
function ajaxLinks(id, container) {

	//looks for all instances of id
	$$(id).each(function(ele) {		

		//what happens when the particular instance is clicked on
		ele.addEvent('click', function(e) {
			e = new Event(e).stop();
			var alink = ele.getProperty('href');
			var url = alink;

			//construct the new URL with a parameter indicating how it should load the page (fully or a portion of it)
			if (alink.indexOf('?') != -1) {
				url += "&amp;ajax=y";
			} else {
				url += "?ajax=y";
			}				

			//this is where the magic happens
			var ajaxLink = new Request.HTML({
				onRequest: function() {}, //what happens during an ajax request is made
				onSuccess: function() { //what happens when an ajax request is completed successfully
					new Fx.Scroll(document.body, {'duration': 'long'}).start(0, 0); //scrolls to the top of the page once your content is loaded
					ajaxLinks('.page-navi a', 'post'); //calls the function again so that it will add ajax post pagination to your newly loaded page
				}, 

				onFailure: function() {}, //what happens when an ajax request fails
				update: $(container) //#post which is your container gets updated
			}).get(url);
		});		    

	});

}

//needed for the MooTools build to be executed
window.addEvent('domready', function(dom){
	ajaxLinks('.page-navi a', 'post'); //Of course all of this will not be completed until you call the function to action
});</pre>
</td>
</tr>
</tbody>
</table>
</div>
<h2>Step 5: Customization</h2>
<p>As you would have probably guessed, this is a very basic implementation of how AJAX post pagination works in WordPress themes.</p>
<p>I would love to let your imagination run wild and see what you come  up. Of course you need to have a little knowledge in CSS to get it done.  Customizations can be made in the 3 different events (<strong>onRequest</strong>, <strong>onSuccess</strong> and <strong>onFailure</strong>).</p>
<p>If you have any doubts or feedback about this how-to. I would love to hear of it.</p>
<p>you can find original post here : <a href="http://www.problogdesign.com/wordpress/how-to-ajax-post-pagination-in-mootools/" target="_blank">http://www.problogdesign.com/wordpress/how-to-ajax-post-pagination-in-mootools/</a></p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.amphee.com/index.php/2010/11/15/how-to-ajax-post-pagination-in-mootools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

