<?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>Earthman&#039;s Blog &#187; Jquery</title>
	<atom:link href="http://earthman.ca/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://earthman.ca</link>
	<description>Website Consultant, Wordpress Web Designer, 80&#039;s DJ, Existentialist, and more...</description>
	<lastBuildDate>Mon, 06 Feb 2012 05:08:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Uploading Files with AJAX</title>
		<link>http://feedproxy.google.com/~r/nettuts/~3/YNUFeG8o474/</link>
		<comments>http://feedproxy.google.com/~r/nettuts/~3/YNUFeG8o474/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 01:24:59 +0000</pubDate>
		<dc:creator>Andrew Burgess</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[file upload]]></category>
		<category><![CDATA[JavaScript & AJAX]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[upload]]></category>
		<category><![CDATA[Jquery]]></category>

		<guid isPermaLink="false">http://net.tutsplus.com/?p=21077</guid>
		<description><![CDATA[I can&#8217;t seem to reach the end of the fun stuff you can do with emerging web technologies. Today, I&#8217;m going to show you how to do something that&#8212;until the last while&#8212;has been almost unprecedented: uploading files via AJAX. 
Oh, s...


Related posts:<ol><li><a href='http://feedproxy.google.com/~r/nettuts/~3/fqdXwXLqAps/' rel='bookmark' title='Permanent Link: How to Upload Files with CodeIgniter and AJAX'>How to Upload Files with CodeIgniter and AJAX</a></li>
<li><a href='http://feedproxy.google.com/~r/nettuts/~3/N1Afbwkp2cM/' rel='bookmark' title='Permanent Link: Build Ajax Data Grids with CodeIgniter and jQuery'>Build Ajax Data Grids with CodeIgniter and jQuery</a></li>
<li><a href='http://feedproxy.google.com/~r/nettuts/~3/r-ywgMnvSEU/' rel='bookmark' title='Permanent Link: Dig into Dojo: NodeList Modules and Ajax'>Dig into Dojo: NodeList Modules and Ajax</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<a href='http://rss.buysellads.com/click.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=21077&c=923498550' ><img src='http://rss.buysellads.com/img.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=21077&c=923498550' border='0' alt='' /></a><p>I can&#8217;t seem to reach the end of the fun stuff you can do with emerging web technologies. Today, I&#8217;m going to show you how to do something that&mdash;until the last while&mdash;has been almost unprecedented: uploading files via AJAX. </p>
<p>Oh, sure, there have been hacks; but if you&#8217;re like me, and feel dirty every time you type <code>iframe</code>, you&#8217;re going to like this a lot. Join me after the jump!</p>
<p><span id="more-21077"></span></p>
<hr />
<p>Why don&#8217;t we get the bad news over with? </p>
<blockquote><p>This doesn&#8217;t work in every browser. However, with some progressive enhancement (or whatever the current buzzword is), we&#8217;ll have an upload page that will work right back to IE6 (albeit without the AJAXy bits).</p></blockquote>
<blockquote class="pullquote"><p>Our AJAX upload will work as long as <code>FormData</code> is available; otherwise, the user will get a normal upload. </p></blockquote>
<p>There are three main components to our project.</p>
<ul>
<li>The <code>multiple</code> attribute on the file <code>input</code> element.</li>
<li>The <code>FileReader</code> object from the new File API.</li>
<li>The <code>FormData</code> object from XMLHttpRequest2.</li>
</ul>
<p>We use the <code>multiple</code> attribute to allow the user to select multiple files for upload (multiple file upload will work normally even if <code>FormData</code> isn&#8217;t available). As you&#8217;ll see, <code>FileReader</code> allows us to show the user thumbnails of the files they&#8217;re uploading (we&#8217;ll be expecting images).</p>
<p>None of our three features work in IE9, so all IE users will get a normal upload experience (though I understand support for `FileReader` is available in IE10 Dev Preview 2). <code>FileReader</code> doesn&#8217;t work in the latest version of Safari (5.1), so they won&#8217;t get the thumbnails, but they&#8217;ll get the AJAX upload and the confirmation message. Finally, Opera 10.50 has <code>FileReader</code> support but not <code>FormData</code> support, so they&#8217;ll get thumbnails, but normal uploads.</p>
<p>With that out of the way, let&#8217;s get coding!</p>
<hr />
<h2><span>Step 1:</span> The Markup and Styling</h2>
<p>Let&#8217;s start with some basic markup and styling. Of course, this isn&#8217;t the main part of this tutorial, I won&#8217;t treat you like a newbie.</p>
<h3>The HTML</h3>
<pre class="html" name="code">&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
	&lt;meta charset=&quot;UTF-8&quot; /&gt;
	&lt;title&gt;HTML5 File API&lt;/title&gt;
	&lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot; /&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;div id=&quot;main&quot;&gt;
		&lt;h1&gt;Upload Your Images&lt;/h1&gt;
		&lt;form method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;  action=&quot;upload.php&quot;&gt;
			&lt;input type=&quot;file&quot; name=&quot;images&quot; id=&quot;images&quot; multiple /&gt;
			&lt;button type=&quot;submit&quot; id=&quot;btn&quot;&gt;Upload Files!&lt;/button&gt;
		&lt;/form&gt;

		&lt;div id=&quot;response&quot;&gt;&lt;/div&gt;
		&lt;ul id=&quot;image-list&quot;&gt;

		&lt;/ul&gt;
	&lt;/div&gt;

	&lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js&quot;&gt;&lt;/script&gt;
	&lt;script src=&quot;upload.js&quot;&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>Pretty basic, eh? We&#8217;ve got a form that posts to <code>upload.php</code>, which we&#8217;ll look at in a second,  and a single input element, of type <code>file</code>. Notice that it has the boolean <code>multiple</code> attribute, which allows the user to select multiple files at once.</p>
<p>That&#8217;s really all there is to see here. Let&#8217;s move on.</p>
<h3>The CSS</h3>
<pre class="css" name="code">body {
	font: 14px/1.5 helvetica-neue, helvetica, arial, san-serif;
	padding:10px;
}

h1 {
	margin-top:0;
}

#main {
	width: 300px;
	margin:auto;
	background: #ececec;
	padding: 20px;
	border: 1px solid #ccc;
}

#image-list {
	list-style:none;
	margin:0;
	padding:0;
}
#image-list li {
	background: #fff;
	border: 1px solid #ccc;
	text-align:center;
	padding:20px;
	margin-bottom:19px;
}
#image-list li img {
	width: 258px;
	vertical-align: middle;
	border:1px solid #474747;
}</pre>
<p>Absolutely no shockers here.</p>
<hr />
<h2><span>Step 2:</span> The PHP</h2>
<p>We need to be able to handle the file uploads on the back end as well, so let&#8217;s cover that next.</p>
<h3>upload.php</h3>
<pre class="php" name="code">&lt;?php

foreach ($_FILES[&quot;images&quot;][&quot;error&quot;] as $key =&gt; $error) {
	if ($error == UPLOAD_ERR_OK) {
		$name = $_FILES[&quot;images&quot;][&quot;name&quot;][$key];
		move_uploaded_file( $_FILES[&quot;images&quot;][&quot;tmp_name&quot;][$key], &quot;uploads/&quot; . $_FILES[&#39;images&#39;][&#39;name&#39;][$key]);
	}
}

echo &quot;&lt;h2&gt;Successfully Uploaded Images&lt;/h2&gt;&quot;;</pre>
<p>Bear in mind that these were the first lines of PHP I&#8217;d written in easily a year (<a href='http://net.tutsplus.com/sessions/ruby-for-newbies/'>I&#8217;m a Ruby guy</a>). You should probably be doing a bit more for security; however, we&#8217;re simply making sure that there are no upload errors. If that&#8217;s the case, we use the built-in <code>move_uploaded_file</code> to move it to an <code>uploads</code> folder. Don&#8217;t forget to make sure that the folder is writable.</p>
<p>So, right now, we should have a working upload form. You choose an image (multiple, if you want to and your browser lets you), click the &#8220;<em>Upload Files!</em>&#8221; button, and you get the message &#8220;<em>Successfully Uploaded Images.</em>&#8221;</p>
<p>Here&#8217;s what our mini-project looks like so far:</p>
<div class="tutorial_image"><img alt='The styled form' src='http://d2o0t5hpnwv4c1.cloudfront.net/1020_ajaxupload/form.png' /></div>
<p>But, come on, it&#8217;s 2011: we want more than that. You&#8217;ll notice that we&#8217;ve linked up jQuery and an <code>upload.js</code> file. Let&#8217;s crack that open now.</p>
<hr />
<h2><span> Step 3:</span> The JavaScript</h2>
<p>Let&#8217;s not waste time: here we go!</p>
<pre class="js" name="code">(function () {
	var input = document.getElementById(&quot;images&quot;),
	    formdata = false;

	if (window.FormData) {
		formdata = new FormData();
		document.getElementById(&quot;btn&quot;).style.display = &quot;none&quot;;
	}

}();</pre>
<p>Here&#8217;s what we start with. We create two variables: <code>input</code> is our file input element; <code>formdata</code> will be used to send the images to the server if the browser supports that. We initialize it to <code>false</code> and then check to see if the browser supports <code>FormData</code>; If it does, we create a new <code>FormData</code> object. Also, if we can submit the images with AJAX, we don&#8217;t need the &#8220;Upload Images!&#8221; button, so we can hide it. Why don&#8217;t we need it? Well, we&#8217;re going to auto-magically upload the images immediately after the user selects them.</p>
<p>The rest of the JavaScript will go inside your anonymous self-invoking function. We next create a little helper function that will show the images once the browser has them:</p>
<pre class="js" name="code">function showUploadedItem (source) {
	var list = document.getElementById(&quot;image-list&quot;),
	    li   = document.createElement(&quot;li&quot;),
	    img  = document.createElement(&quot;img&quot;);
  	img.src = source;
  	li.appendChild(img);
	list.appendChild(li);
}</pre>
<p>The function takes one parameter: the image source (we&#8217;ll see how we get that soon). Then, we simply find the list in our markup and create a list item and image. We set the image source to the source we received, put the image in the list item, and put the list item in the list. Voila!</p>
<p>Next, we have to actually take the images, display them, and upload them. As we&#8217;ve said, we&#8217;ll do this when the <code>onchange</code> event is fired on the input element.</p>
<pre class="js" name="code">if (input.addEventListener) {
	input.addEventListener(&quot;change&quot;, function (evt) {
		var i = 0, len = this.files.length, img, reader, file;

		document.getElementById("response").innerHTML = "Uploading . . ."

		for ( ; i &lt; len; i++ ) {
			file = this.files[i];

			if (!!file.type.match(/image.*/)) {

			}
		}

	}, false);
}</pre>
<blockquote class="pullquote"><p>We don’t have to worry about IE’s proprietary event model, because IE9+ supports the standard addEventListener function.</p></blockquote>
<p>There&#8217;s more, but let&#8217;s start with this. First off, we don&#8217;t have to worry about IE&#8217;s proprietary event model, because IE9+ supports the standard <code>addEventListener</code> function (and IE9 and down don&#8217;t support our new features).</p>
<p>So, what do we want to do when the user has selected files? First, we create a few variables. The only important one right now is <code>len = this.files.length</code>. The files that the user has selected will be accessible from the object <code>this.files</code>. Right now, we&#8217;re only concerned with the <code>length</code> property, so we can loop over the files &#8230;</p>
<p>&#8230; which is exactly what we&#8217;re doing next. Inside our loop, we set the current file to <code>file</code> for ease of access. Next thing we do is confirm that the file is an image. We can do this by comparing the <code>type</code> property with a regular expression. We&#8217;re looking for a type that starts with &#8220;image&#8221; and is followed by anything. (The double-bang in front just converts the result to a boolean.)</p>
<p>So, what do we do if we have an image on our hands?</p>
<pre class="js" name="code">if ( window.FileReader ) {
	reader = new FileReader();
	reader.onloadend = function (e) {
		showUploadedItem(e.target.result);
	};
	reader.readAsDataURL(file);
}
if (formdata) {
	formdata.append(&quot;images[]&quot;, file);
}</pre>
<p>We check to see if the browser supports creating <code>FileReader</code> objects. If it does, we&#8217;ll create one. </p>
<p>Here&#8217;s how we use a <code>FileReader</code> object: We&#8217;re going to pass our <code>file</code> object to the <code>reader.readAsDataURL</code> method. This creates a <a href='http://en.wikipedia.org/wiki/Data_Url'>data url</a> for the uploaded image. It doesn&#8217;t work the way you might expect, though. The data url isn&#8217;t passed back from the function. Instead, the data url will be part of an event object. </p>
<p>With that in mind, we&#8217;ll need to register a function on the <code>reader.onloadend</code> event. This function takes an event object, by which we get the data url: it&#8217;s at <code>e.target.result</code> (yes, <code>e.target</code> is the <code>reader</code> object, but I had issues when using <code>reader</code> in place of <code>e.target</code> inside this function). We&#8217;re just going to pass this data url to our <code>showUploadedItem</code> function (which we wrote above).</p>
<p>Next, we check for the <code>formdata</code> object. Remember, if the browser supports <code>FormData</code>, <code>formdata</code> will be a <code>FormData</code> object; otherwise, it will be <code>false</code>. So, if we have a <code>FormData</code> object, we&#8217;re going to call the <code>append</code> method. The purpose of a <code>FormData</code> object is to hold values that you&#8217;re submitting via a form; so, the <code>append</code> method simply takes a key and a value. In our case, our key is <code>images[]</code>; by adding the square-brackets to the end, we make sure each time we <code>append</code> another value, we&#8217;re actually appending it to that array, instead of overwriting the <code>image</code> property.</p>
<p>We&#8217;re almost done. In our for loop, we&#8217;ve displayed each of the images for the user and added them to the <code>formdata</code> object. Now, we just need to upload the images. Outside the <code>for</code> loop, here&#8217;s the last piece of our puzzle:</p>
<pre class="js" name="code">if (formdata) {
	$.ajax({
		url: &quot;upload.php&quot;,
		type: &quot;POST&quot;,
		data: formdata,
		processData: false,
		contentType: false,
		success: function (res) {
			document.getElementById(&quot;response&quot;).innerHTML = res;
		}
	});
}</pre>
<p>Again, we have to make sure we have <code>FormData</code> support; if we don&#8217;t, the &#8220;Upload Files!&#8221; button will be visible, and that&#8217;s how the user will upload the photos. However, if we have <code>FormData</code> support, we&#8217;ll take care of uploading via AJAX. We&#8217;re using jQuery to handle all the oddities of AJAX across browsers. </p>
<p>You&#8217;re probably familiar with jQuery&#8217;s <code>$.ajax</code> method: you pass it an options object. The <code>url</code>, <code>type</code>, and <code>success</code> properties should be obvious. The <code>data</code> property is our <code>formdata</code> object. Notice those <code>processData</code> and <code>contentType</code> properties. According to jQuery&#8217;s documentation, <code>processData</code> is <code>true</code> by default, and will process and transform the data into a query string. We don&#8217;t want to do that, so we set this to <code>false</code>. We&#8217;re also setting <code>contentType</code> to <code>false</code> to make sure that data gets to the server as we expect it to.</p>
<p>And that&#8217;s it. Now, when the user loads the page, they see this:</p>
<div class="tutorial_image"><img alt='Tutorial Image' src='http://d2o0t5hpnwv4c1.cloudfront.net/1020_ajaxupload/ajax-start.png' /></div>
<p>And after they select the images, they&#8217;ll see this:</p>
<div class="tutorial_image"><img alt='Tutorial Image' src='http://d2o0t5hpnwv4c1.cloudfront.net/1020_ajaxupload/ajax-upload.png' /></div>
<p>And the images have been uploaded:</p>
<div class="tutorial_image"><img alt='Tutorial Image' src='http://d2o0t5hpnwv4c1.cloudfront.net/1020_ajaxupload/ajax-finder.png' /></div>
<hr />
<h2>That&#8217;s a Wrap!</h2>
<p>Uploading files via AJAX is pretty cool, and it&#8217;s great that these new technologies support that without the need for lengthy hacks. If you&#8217;ve got any questions about what we&#8217;ve done here, hit those comments! Thank you so much for reading!</p>
<p><a href="http://feedads.g.doubleclick.net/~a/vPtdWDyxW5PzZ_R__AM1dqCm9Hg/0/da"><img src="http://feedads.g.doubleclick.net/~a/vPtdWDyxW5PzZ_R__AM1dqCm9Hg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/vPtdWDyxW5PzZ_R__AM1dqCm9Hg/1/da"><img src="http://feedads.g.doubleclick.net/~a/vPtdWDyxW5PzZ_R__AM1dqCm9Hg/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/nettuts?a=YNUFeG8o474:SBjHKSbkOPc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/nettuts?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=YNUFeG8o474:SBjHKSbkOPc:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/nettuts?i=YNUFeG8o474:SBjHKSbkOPc:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=YNUFeG8o474:SBjHKSbkOPc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/nettuts?i=YNUFeG8o474:SBjHKSbkOPc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=YNUFeG8o474:SBjHKSbkOPc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/nettuts?i=YNUFeG8o474:SBjHKSbkOPc:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=YNUFeG8o474:SBjHKSbkOPc:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/nettuts?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/nettuts/~4/YNUFeG8o474" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://net.tutsplus.com/tutorials/javascript-ajax/uploading-files-with-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Plugins + Jquery</title>
		<link>http://earthman.ca/web-design/plugins-jquery/</link>
		<comments>http://earthman.ca/web-design/plugins-jquery/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 10:22:30 +0000</pubDate>
		<dc:creator>Earthman</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Website Consulting]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Jquery]]></category>
		<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[Wordpress Plugins]]></category>

		<guid isPermaLink="false">http://earthman.ca/?p=23</guid>
		<description><![CDATA[Hi Fellow WordPress Fans! Here are some WordPress plugins you will likely find useful&#8230; My Page Order &#8211; Easy drag and drop ordering of your pages &#8211; Access under Pages &#62; Page Order Cleaner Gallery &#8211; Makes it easy to integrate the Worpress built in photo gallery feature with Shadowbox (or other lightbox scripts) &#8211; or just simply removes the styles that wordpress injects natively, so you can use your own more easily ShadowboxJS - Activates overlay lightbox-style effects for your Image links.  Also works with Iframes, HTML content, Videos, SWF, etc.  Super frikkin cool!  Check out what it can do at:http://mjijackson.com/shadowbox &#8211; The wordpress plugin install will give you immediate access to all the functionality. WP-SIFR &#8211; Change Page titles (h1,h2, etc) into Flash-Rendered Text, using the SIFR font of your choice (find em on google) &#8211; Degrades gracefully and doesn&#8217;t affect accessibility at all CFORMSII &#8211; get the latest version &#8211; Stop coding forms, auto-verification, Captcha support etc.  YEAH! &#8212;- Also, for front end Javascript fancy FX &#8211; Check out JQuery http://jquery.com/ There are frameworks (prototype, mootools) but I like Jquery so far &#8211; the syntax is easy, and there are lots of plugins around.  Downside, sometimes can [...]


Related posts:<ol><li><a href='http://net.tutsplus.com/tutorials/wordpress/create-wordpress-plugins-with-oop-techniques/' rel='bookmark' title='Permanent Link: Create WordPress Plugins with OOP Techniques'>Create WordPress Plugins with OOP Techniques</a></li>
<li><a href='http://earthman.ca/css/wanted-jquerycss-ninja/' rel='bookmark' title='Permanent Link: Wanted &#8211; JQuery/CSS Ninja'>Wanted &#8211; JQuery/CSS Ninja</a></li>
<li><a href='http://feedproxy.google.com/~r/nettuts/~3/HREm42bOVe8/' rel='bookmark' title='Permanent Link: What you Should be Excited About in jQuery UI 1.9'>What you Should be Excited About in jQuery UI 1.9</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hi Fellow <span class="il">WordPress</span> Fans!</p>
<p>Here are some <span class="il">WordPress</span> plugins you will likely find useful&#8230;</p>
<p><strong>My Page Order</strong> &#8211; Easy drag and drop ordering of your pages &#8211; Access under Pages &gt; Page Order<br />
<strong><br />
Cleaner Gallery</strong> &#8211; Makes it easy to integrate the Worpress built in photo gallery feature with Shadowbox (or other lightbox scripts) &#8211; or just simply removes the styles that <span class="il">wordpress</span> injects natively, so you can use your own more easily</p>
<p><strong>ShadowboxJS </strong>- Activates overlay lightbox-style effects for your Image links.  Also works with Iframes, HTML content, Videos, SWF, etc.  Super frikkin cool!  Check out what it can do at:<a href="http://mjijackson.com/shadowbox" target="_blank">http://mjijackson.com/shadowbox</a> &#8211; The <span class="il">wordpress</span> plugin install will give you immediate access to all the functionality.<br />
<strong><br />
WP-SIFR</strong> &#8211; Change Page titles (h1,h2, etc) into Flash-Rendered Text, using the SIFR font of your choice (find em on google) &#8211; Degrades gracefully and doesn&#8217;t affect accessibility at all<br />
<strong><br />
CFORMSII</strong> &#8211; get the latest version &#8211; Stop coding forms, auto-verification, Captcha support etc.  YEAH!</p>
<p>&#8212;-</p>
<p>Also, for front end Javascript fancy FX &#8211; Check out <span class="il">JQuery</span> <a href="http://jquery.com/" target="_blank">http://<span class="il">jquery</span>.com/</a></p>
<p>There are frameworks (prototype, mootools) but I like <span class="il">Jquery</span> so far &#8211; the syntax is easy, and there are lots of plugins around.  Downside, sometimes can get heavy on load times if you get too many plugins involved.</p>
<p>AND, <span style="text-decoration: underline"><strong><span class="il">Jquery</span> is already bundled in <span class="il">WordPress</span></strong></span> which makes the install easy as pie!</p>
<p>To activate and use the core in your <span class="il">WordPress</span> theme, just do the following:</p>
<p>In your theme&#8217;s <strong>functions.php</strong> file, include the following function call:</p>
<div style="margin-left: 40px"><strong>wp_enqueue_script(&#8216;<span class="il">jquery</span>&#8216;);<br />
</strong></div>
<p>That will load the <span class="il">Jquery</span> 1.2.6 base file in your wp_head, and put the script into your page&#8217;s head section automagically.</p>
<p>Then, copy the following into your template&#8217;s <strong>header.php</strong> file,  <strong>AFTER </strong>&lt;?php wp_head(); ?&gt; and after all your stylesheets and CSS:</p>
<div style="margin-left: 40px"><strong>&lt;script type=&#8221;text/javascript&#8221;&gt;</strong></p>
<div style="margin-left: 40px"><strong><span class="il">jQuery</span>.noConflict();</strong> // loads <span class="il">Jquery</span> and makes sure it won&#8217;t conflict with other libraries<br />
<strong> var $ = <span class="il">jQuery</span>; </strong>// assigns $ to the <span class="il">Jquery</span> object/library for ease of use and plugin file access</p>
<p><strong> $(document).ready(function() {</strong> <strong> </strong> // this is <span class="il">jquery</span>&#8216;s version of window.onload</div>
<div style="margin-left: 80px"><strong> </strong>//<span class="il">jquery</span> &#8216;on page load&#8217; code assignments go here</p>
<p><strong> alert(&#8216;page loaded&#8217;);</strong> //sample of action to perform on page load</div>
<div style="margin-left: 40px"><strong> });</strong></div>
<p><strong>&lt;/script&gt; </strong></div>
<p>There, with the snippet above you will see that an alert pops up on page load, showing that <span class="il">Jquery</span> is up and working.</p>
<p>Have fun!!!!<br />
<span style="color: #888888"> T<br />
</span></p>


<p>Related posts:<ol><li><a href='http://net.tutsplus.com/tutorials/wordpress/create-wordpress-plugins-with-oop-techniques/' rel='bookmark' title='Permanent Link: Create WordPress Plugins with OOP Techniques'>Create WordPress Plugins with OOP Techniques</a></li>
<li><a href='http://earthman.ca/css/wanted-jquerycss-ninja/' rel='bookmark' title='Permanent Link: Wanted &#8211; JQuery/CSS Ninja'>Wanted &#8211; JQuery/CSS Ninja</a></li>
<li><a href='http://feedproxy.google.com/~r/nettuts/~3/HREm42bOVe8/' rel='bookmark' title='Permanent Link: What you Should be Excited About in jQuery UI 1.9'>What you Should be Excited About in jQuery UI 1.9</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://earthman.ca/web-design/plugins-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

