<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ryan Pharis &#187; Javascript</title>
	<atom:link href="http://ryanpharis.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://ryanpharis.com</link>
	<description>Dallas Forth Worth Metroplex, Texas Freelance PHP CodeIgniter Web Developer &#38; WordPress as a CMS Consultant</description>
	<lastBuildDate>Mon, 15 Mar 2010 17:29:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>jQuery 1.3 With PHP by Kae Verans Book Review</title>
		<link>http://ryanpharis.com/2009/12/jquery-1-3-with-php-by-kae-verans-book-review/</link>
		<comments>http://ryanpharis.com/2009/12/jquery-1-3-with-php-by-kae-verans-book-review/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 19:28:30 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://ryanpharis.com/?p=95</guid>
		<description><![CDATA[I have read through the newest jQuery book out there: jQuery 1.3 With PHP from Packt Publishing by Kae Verans. It&#8217;s targeted at experienced PHP developers who want to enhance their applications on the front end with JavaScript and Ajax functionality and uses the jQuery library to do so. You do not necessarily need JavaScript [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.packtpub.com/jquery-1-3-with-php/mid/171209gv1rve?utm_source=ryanpharis.com&amp;utm_medium=affiliate&amp;utm_content=blog&amp;utm_campaign=mdb_001855"><img class="alignleft size-full wp-image-96" title="jQuery-1.3-with-PHP-book" src="http://ryanpharis.com/wp-content/uploads/2009/12/jQuery-1.3-with-PHP-book.png" alt="jQuery-1.3-with-PHP-book" width="100" height="123" /></a>I have read through the newest jQuery book out there: <a title="jQuery 1.3 with PHP book review" href="http://www.packtpub.com/jquery-1-3-with-php/mid/171209gv1rve?utm_source=ryanpharis.com&amp;utm_medium=affiliate&amp;utm_content=blog&amp;utm_campaign=mdb_001855" target="_blank"><strong>jQuery 1.3 With PHP</strong></a> from Packt Publishing by Kae Verans. It&#8217;s targeted at <strong>experienced PHP developers</strong> who want to enhance their applications on the front end with JavaScript and Ajax functionality and uses the jQuery library to do so. You do not necessarily need JavaScript or jQuery experience to follow along, although it helps. If you are a front end developer who already knows jQuery inside and out and are looking to learn more about PHP, this book is not really geared for you.</p>
<p>But If you&#8217;re like me, you are not brand new to jQuery and it&#8217;s powerful features and ease of use. You probably have already used it in some of your projects and have used the excellent <a href="http://docs.jquery.com/Main_Page" target="_blank">documentation</a> found on their site. As good as the official docs are, there is always room for improvement by using more robust and clearer examples. That&#8217;s exactly what you get with &#8220;<a title="jQuery book" href="http://www.packtpub.com/jquery-1-3-with-php/mid/171209gv1rve?utm_source=ryanpharis.com&amp;utm_medium=affiliate&amp;utm_content=blog&amp;utm_campaign=mdb_001855" target="_blank">jQuery 1.3 with PHP</a>&#8220;.</p>
<p>The examples you can look forward to building include tabs, accordions, form validation, file management, calendars, image manipulation, drag and drop, and data tables. Your PHP skills, along with the excellent and well explained jQuery code found throughout the book for each example, will allow you to add modern and responsive elements very easily and quickly.</p>
<p>If you are a veteran PHP developer and are looking to get started in the front end UI of your applications and web sites, this is the right book with the right angle for you. If you are a MVC framework guy like I am, the server-side PHP code provided is easily adapted to put into your controllers and views.</p>
<p>Disclosure: I was given a copy of the book to review by Packt Publishing. If you want to purchase the book and use a link from my site, I receive a commission.</p>
]]></content:encoded>
			<wfw:commentRss>http://ryanpharis.com/2009/12/jquery-1-3-with-php-by-kae-verans-book-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ajax for WordPress Plugins Using jQuery Tutorial</title>
		<link>http://ryanpharis.com/2008/10/ajax-for-wordpress-plugins-using-jquery/</link>
		<comments>http://ryanpharis.com/2008/10/ajax-for-wordpress-plugins-using-jquery/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 01:30:22 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://ryanpharis.com/?p=33</guid>
		<description><![CDATA[I recently had the need to perform some ajax functions on the backend of Texas Tech Today and wasn&#8217;t sure exactly how to go about it. So after a search, I found this great explanation: Simplified AJAX For WordPress Plugin Developers using Jquery. But it stops short of explaining how to receive some data from [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had the need to perform some ajax functions on the backend of <a title="Texas Tech Today" href="http://today.ttu.edu" target="_blank">Texas Tech Today</a> and wasn&#8217;t sure exactly how to go about it. So after a search, I found this great explanation: <a title="Simplified AJAX For WordPress Plugin Developers using Jquery" href="http://amiworks.co.in/talk/simplified-ajax-for-wordpress-plugin-developers-using-jquery" target="_blank">Simplified AJAX For WordPress Plugin Developers using Jquery</a>. But it stops short of explaining how to receive some data from a POST, give it to PHP to do something with, and then return a result back to the form.</p>
<p>So, I thought I would detail how to do that in WordPress in a plugin.</p>
<p>The plugin just has a basic options page (Settings -&gt; Ajax4WP) and lets you save an option to the database via ajax. Go ahead and <a title="Ajax for WordPress plugins" href="http://ryanpharis.com/wp-content/uploads/2008/10/ajax4wp.zip">download</a> and install it; you&#8217;ll see how simple it is.</p>
<p><strong>1. Create a php file that will have our javascript code, and save it into your plugins folder.</strong></p>
<p>The reason we need our javascript code to be in a PHP file is to get the &#8220;get_option(&#8216;siteurl&#8217;)&#8221; value dynamically, since we&#8217;ll need that to reference our PHP file with the ajax function.</p>
<p>js-Ajax4WP.php (<a title="Ajax for WordPress plugins" href="http://ryanpharis.com/wp-content/uploads/2008/10/ajax4wp.zip">download</a> the plugin files)</p>
<pre>&lt;?php
include('../../../wp-config.php');
$site_url = get_option('siteurl');
?&gt;
jQuery(document).ready(function() {

   //when the link with the id of save_settings is clicked, get the value of the text field and start doing the ajax stuff
   jQuery('#save_settings').click(function() {

      var Ajax4WP_test_setting = jQuery("#Ajax4WP_test_setting").val();

      //action is the name of the php function in your main plugin file
      jQuery.post("&lt;?php echo $site_url; ?&gt;/wp-admin/admin-ajax.php", {action:"Ajax4WP_save_settings", 'cookie': encodeURIComponent(document.cookie), Ajax4WP_test_setting:Ajax4WP_test_setting},
      function(res)
      {
         var message_result = eval('(' + res + ')');
         if (!message_result.success) {
            jQuery("#Ajax4WP_test_setting").css("border","2px solid #cc0000");
         }
         alert(message_result.message + ' ' + message_result.setting);
      });

      return false;
   });

});</pre>
<p>This is jQuery ajax code that takes the value of a text field and passes it to Ajax4WP_save_settings() in our plugin file. We use <a title="jQuery.post" href="http://docs.jquery.com/Ajax/jQuery.post" target="_blank">jQuery.post</a> to define a post variable (Ajax4WP_test_setting) that PHP can use.</p>
<p>Once the plugin code does its thing on the server (step 2 below), it returns the result back to this function at &#8220;function(res)&#8221;. Then we eval the json result and use an alert to display a message.</p>
<p><strong>2. Create your standard plugin file and put in the Ajax4WP_save_settings function.</strong></p>
<p>Ajax4WP.php (<a title="Ajax for WordPress plugins" href="http://ryanpharis.com/wp-content/uploads/2008/10/ajax4wp.zip">download</a> the plugin files)</p>
<pre>...

// our ajax action:
add_action('wp_ajax_Ajax4WP_save_settings', array(&amp;$this, 'Ajax4WP_save_settings'), 10);

function Ajax4WP_save_settings()
		{
		   $name = 'Ajax4WP_test_setting';
			$value = $_POST['Ajax4WP_test_setting'];

			if ($value == "") {
				$message_result = array(
					'setting' =&gt; "",
					'message' =&gt; 'Please enter a Setting Value!',
					'success' =&gt; FALSE
	         );
			}
			else {
			   update_option($name, $value);
				$message_result = array(
					'setting' =&gt; $value,
					'message' =&gt; 'Saved! You entered:',
				   'success' =&gt; TRUE
	         );
			}
			echo json_encode($message_result);
			exit;
		}
...</pre>
<p>This is standard PHP to process a POST request. When we&#8217;re through, we echo the <a title="json_encode - php 5.2 only" href="http://us.php.net/manual/en/function.json-encode.php" target="_blank">json_encode()</a> result. NOTE: json_encode is a PHP &gt;= 5.2 only function, so be sure you are up to date on your PHP install.</p>
<p><strong>3. Make a php file that will contain basic html and will get included on our settings page</strong></p>
<p>Ajax4WP-settings.php (<a title="Ajax for WordPress plugins" href="http://ryanpharis.com/wp-content/uploads/2008/10/ajax4wp.zip">download</a> the plugin files)</p>
<pre>&lt;div id="Ajax4WP Settings" class="inside" style="margin-left: 29px; width: 200px;"&gt;

   &lt;h3&gt;Ajax4WP Settings&lt;/h3&gt;

   &lt;div id="loading_message"&gt;&lt;/div&gt;

   &lt;p&gt;
   &lt;label for="Ajax4WP_test_setting"&gt;Setting Value:&lt;/label&gt;
   &lt;br /&gt;
   &lt;input type="text" id="Ajax4WP_test_setting" name="Ajax4WP_test_setting" value="&lt;?php if (isset($this-&gt;Ajax4WP_test_setting)) { echo $this-&gt;Ajax4WP_test_setting; } ?&gt;" size="20" /&gt;
   &lt;/p&gt;

   &lt;p&gt;&lt;a href="#" id="save_settings" class="button button-highlighted"&gt;Save Settings&lt;/a&gt;&lt;/p&gt;

&lt;/div&gt;</pre>
<p>This is just a &#8220;stub&#8221; and gets included in our plugin. That way we don&#8217;t have a lot of html code mucking up the main plugin file. You can see what&#8217;s going on better in the source code when you <a title="How to use Ajax in your WordPress plugins" href="http://ryanpharis.com/wp-content/uploads/2008/10/ajax4wp.zip">download the files</a>.</p>
<p>I hope that helps you out if you are wondering how to use jQuery and ajax in your WordPress plugins. Please leave a comment if you have any questions. Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://ryanpharis.com/2008/10/ajax-for-wordpress-plugins-using-jquery/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
