<?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>Johan de Bruin &#187; AJAX</title>
	<atom:link href="http://www.johandebruin.com/c/programacion/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.johandebruin.com</link>
	<description>Programación en php, tutorial de api wordpress y posicionamiento en buscadores seo.</description>
	<lastBuildDate>Sun, 05 Feb 2012 15:18:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Mostrar elementos ocultados con javascript</title>
		<link>http://www.johandebruin.com/mostrar-elementos-ocultados-con-javascript/</link>
		<comments>http://www.johandebruin.com/mostrar-elementos-ocultados-con-javascript/#comments</comments>
		<pubDate>Sat, 05 Jun 2010 17:55:26 +0000</pubDate>
		<dc:creator>Johan</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mostrar contenido]]></category>
		<category><![CDATA[ocultar contenido]]></category>
		<category><![CDATA[snnipet]]></category>

		<guid isPermaLink="false">http://www.johandebruin.com/?p=593</guid>
		<description><![CDATA[Aquí una rápida pieza de código que permitira ocultar contenido para luego mostrarlo si así lo quiere el usuario. Empleamos javascript junto al reconocimiento DOM de elementos html para definir el contenido de un div. &#60;head&#62; &#60;script type=&#34;text/javascript&#34;&#62; function mostrar() { document.getElementById(&#34;contenedor&#34;).innerHTML = 'hola mundo'; } &#60;/script&#62; &#60;/head&#62; &#60;body&#62; &#60;a href=&#34;javascript://&#34; onclick=&#34;mostrar()&#34;&#62;Mostrar contenido del contenedor&#60;/a&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Aquí una rápida pieza de código que permitira ocultar contenido para luego mostrarlo si así lo quiere el usuario. Empleamos javascript junto al reconocimiento DOM de elementos html para definir el contenido de un div.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;head&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function mostrar()
{
	document.getElementById(&quot;contenedor&quot;).innerHTML = 'hola mundo';
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;a href=&quot;javascript://&quot; onclick=&quot;mostrar()&quot;&gt;Mostrar contenido del contenedor&lt;/a&gt;
&lt;div id=&quot;contenedor&gt;
&lt;!-- Este contenedo ahora mismo esta vacio --&gt;
&lt;/div&gt;</pre></div></div>

<p><span id="more-593"></span><br />
Y así de facil, únicamente tenemos que hacer referencia con el atributo de onclick a la función que insertara contenido al elemento que queramos mostrar, también sirve para cambiar de imagen, únicamente deberiamos usar el atributo de javascript document.getElementById(&#8220;contenedor&#8221;).src al hacer click a la imagen&#8230; </p>
]]></content:encoded>
			<wfw:commentRss>http://www.johandebruin.com/mostrar-elementos-ocultados-con-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Integrar jquery con wordpress</title>
		<link>http://www.johandebruin.com/integrar-jquery-con-wordpress/</link>
		<comments>http://www.johandebruin.com/integrar-jquery-con-wordpress/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 20:01:13 +0000</pubDate>
		<dc:creator>Johan de Bruin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[API wordpress]]></category>
		<category><![CDATA[header hook wordpress]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Programacion]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.johandebruin.com/?p=312</guid>
		<description><![CDATA[WordPress permite gracias a su api usar códigos de jquery, con esta libreria de javascript permitirás establecer una nueva forma de funcionamiento de las páginas web. Para usar jquery tendremos que invocar su código contenido en un archivo .js gracias a una serie de funciones que wordpress nos proporciona. Para poder invocar el directorio del [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress permite gracias a su api usar códigos de jquery, con esta libreria de javascript permitirás establecer una nueva forma de funcionamiento de las páginas web. Para usar jquery tendremos que invocar su código contenido en un archivo .js gracias a una serie de funciones que wordpress nos proporciona.</p>
<p><a href="http://www.johandebruin.com/wp-content/uploads/2010/01/jquerybasico.gif"><img class="size-full wp-image-384 alignnone" title="jquery basico" src="http://www.johandebruin.com/wp-content/uploads/2010/01/jquerybasico.gif" alt="" width="806" height="387" /></a></p>
<p><span id="more-312"></span><br />
Para poder invocar el directorio del plugin, podemos usar el siguiente snnipet de wordpress:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$root_codigo</span> <span style="color: #339933;">=</span> trailingslashit<span style="color: #009900;">&#40;</span> WP_PLUGIN_URL<span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span> plugin_basename<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Ahora que ya tenemos establecida la url de la base donde se mantendrán distintos códigos, (como el .js con el jquery), podemos decir a wordpress que incluya susodicho código entre sus códigos:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> codigo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'un_nombre_script'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$root_codigo</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/codigojquery.js'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//Linea de código para pasar parametros al jquery</span>
wp_localize_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'un_nombre_script'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'clase'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'algun_parametro'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'valor'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_print_scripts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'codigo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Usamos wp_localize_script para pasar los parámetros a la función jquery, en este caso la ruta del plugin, si quisieramos acceder en el jquery a dicho parámetro podemos usar la clase que enviamos asi: <em>clase.algun_parametro</em>.</p>
<p>Por último, un ejemplo de la estructura que podria tener codigojquery.js:</p>

<div class="wp_syntax"><div class="code"><pre class="javascritp" style="font-family:monospace;">$(document).ready(function())
{
     $(&quot;a&quot;).click(function()
     {
          alert(&quot;Gracias por tu visita!&quot;);
     });
});</pre></div></div>

<p>Por último, aquí un video de introducción sobre jquery:<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/Hk5oXFtYLwE&amp;hl=es_ES&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/Hk5oXFtYLwE&amp;hl=es_ES&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.johandebruin.com/integrar-jquery-con-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actualizar tu feed de twitter con AJAX</title>
		<link>http://www.johandebruin.com/actualizar-tu-feed-de-twitter-con-ajax/</link>
		<comments>http://www.johandebruin.com/actualizar-tu-feed-de-twitter-con-ajax/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 12:43:13 +0000</pubDate>
		<dc:creator>Johan de Bruin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Programacion]]></category>

		<guid isPermaLink="false">http://www.johandebruin.com/?p=183</guid>
		<description><![CDATA[Hoy con la nueva categoria AJAX os mostrare un código en AJAX que os permitira actualizar los mensajes de twitter sin tener que actualizar la página. Para ello, tendremos que dividir el código de programación en 2 archivos. el código de AJAX se mostrará en el archivo cliente, mientras que el código twitterfeed.php será de [...]]]></description>
			<content:encoded><![CDATA[<p>Hoy con la nueva categoria AJAX os mostrare un código en AJAX que os permitira actualizar los mensajes de twitter sin tener que actualizar la página. Para ello, tendremos que dividir el código de programación en 2 archivos. el código de AJAX se mostrará en el <strong>archivo cliente</strong>, mientras que el código <strong>twitterfeed.php </strong>será de donde obtendrá los nuevos feed el código en AJAX.<br />
<span id="more-183"></span><br />
Primero definiremos el código javascript necesario para poder actualizar el feed de twitter. Emplazaremos este código junto al resto de código javascript de la página (orden porfavor).</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #006600; font-style: italic;">//Primero creamos el objeto XMLHttpRequest que nos permite establecer conexiones HTTP</span>
xmlhttp <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//Con esta función actualizamos el contenido de cualquier div con el de algún archivo</span>
<span style="color: #003366; font-weight: bold;">function</span> makerequest<span style="color: #009900;">&#40;</span>serverPage<span style="color: #339933;">,</span> objID<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> obj <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>objID<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    xmlhttp.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;GET&quot;</span><span style="color: #339933;">,</span> serverPage<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    xmlhttp.<span style="color: #660066;">onreadystatechange</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>xmlhttp.<span style="color: #660066;">readyState</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">4</span> <span style="color: #339933;">&amp;&amp;</span> xmlhttp.<span style="color: #000066;">status</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">200</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            obj.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> xmlhttp.<span style="color: #660066;">responseText</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    xmlhttp.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Ahora, debemos definir el código HTML, la primera vez que mostremos el feed de twitter lo haremos con PHP con tal de que los buscadores puedan rastrearlo, luego usaremos un botón para actualizar el feed usando AJAX y el usuario no tenga que estar refresando la página web.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;ul&gt;
    &lt;div id=&quot;twitterfeed&quot;&gt;
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;twitterfeed.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;/div&gt;
&lt;/ul&gt;
&lt;center&gt;&lt;input type=&quot;button&quot; onclick=&quot;makerequest('twitterfeed.php','twitterfeed')&quot; value=&quot;Actualizar&quot;&gt;&lt;/center&gt;</pre></div></div>

<p>Ahora solo nos queda crear <strong>twitterfeed.php</strong>, para ello usaremos una función que ya publique con anterioridad: <a title="feed twitter php" href="http://www.johandebruin.com/mostrar-feed-de-busqueda-en-twitter/">Mostrar feed de busqueda en twitter</a></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> twitterfeed<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;li&gt;'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&lt;/li&gt;'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'johandebruin'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'5'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Y con esto queda terminado el código, podeis verlo funcionando en esta página web: <a href="http://www.blognexusone.es">Blog nexus one</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.johandebruin.com/actualizar-tu-feed-de-twitter-con-ajax/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

