<?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>Linea de Codigo &#187; AJAX</title>
	<atom:link href="http://lineadecodigo.com/categoria/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://lineadecodigo.com</link>
	<description>/* Programación en la red */</description>
	<lastBuildDate>Wed, 16 May 2012 06:00:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Repaginar datos con AJAX</title>
		<link>http://lineadecodigo.com/ajax/repaginar-datos-con-ajax/</link>
		<comments>http://lineadecodigo.com/ajax/repaginar-datos-con-ajax/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 23:09:56 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[DIV]]></category>
		<category><![CDATA[getElementById]]></category>
		<category><![CDATA[getParameter]]></category>
		<category><![CDATA[innerHTML]]></category>
		<category><![CDATA[LI]]></category>
		<category><![CDATA[Microsoft.XMLHTTP]]></category>
		<category><![CDATA[onreadystatechange]]></category>
		<category><![CDATA[open]]></category>
		<category><![CDATA[responseText]]></category>
		<category><![CDATA[send]]></category>
		<category><![CDATA[UL]]></category>
		<category><![CDATA[XMLHttpRequest]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/?p=1852</guid>
		<description><![CDATA[Una de las cosas que nos permite AJAX es realizar peticiones asíncronas, las cuales solo recarguen una parte de la página. Esto nos da la posibilidad de dar la sensación de velocidad de cara al usuario. Un caso ejemplo es el de la repaginación de datos. Es decir, tener una lista de elementos dentro de [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-1852'></div><g:plusone size='medium' href='http://lineadecodigo.com/ajax/repaginar-datos-con-ajax/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fajax%2Frepaginar-datos-con-ajax%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/ajax/repaginar-datos-con-ajax/" data-count="horizontal" data-text="Repaginar datos con AJAX" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>Una de las cosas que nos permite <a href="http://www.manualweb.net/tutorial-ajax/" title="AJAX">AJAX</a> es realizar peticiones asíncronas, las cuales solo recarguen una parte de la página. Esto nos da la posibilidad de dar la sensación de velocidad de cara al usuario. Un caso ejemplo es el de la repaginación de datos. Es decir, tener una lista de elementos dentro de las páginas e ir avanzando o retrocediendo en el listado. Buscando no afectar al resto de la página.</p>
<p>En el ejemplo repaginar datos con <a href="http://www.manualweb.net/tutorial-ajax/" title="AJAX">AJAX</a> nos vamos a centrar en la parte cliente de petición (en nuestra página <a href="http://www.manualweb.net/tutorial-html/" title="HTML">HTML</a>). No entraremos en detalle de la construcción de la parte servidor. Si bien, dejo pendiente el escribir un artículo completo que utilice <a href="http://www.manualweb.net/tutorial-ajax/" title="AJAX">AJAX</a>, PHP y acceso a datos MySQL. Lo cual nos dejará ver el proceso entero de una forma más detallada.</p>
<p>Empezaremos definiendo la página del servidor que nos devuelva los datos. Esta puede estar construida en cualquier tecnología del lado del servidor. Véase <a href="http://www.manualweb.net/tutorial-asp/" title="ASP">ASP</a>, <a href="http://www.manualweb.net/tutorial-php/" title="PHP">PHP</a>, <a href="http://www.manualweb.net/tutorial-jsp/" title="JSP">JSP</a>,... En nuestro caso vamos a crear una pequeña página en <a href="http://www.manualweb.net/tutorial-jsp/" title="JSP">JSP</a>.</p>
<p>Esta página recibe un parámetro denominado "página". Según el valor que le llegue como parámetro devolverá una lista <a href="http://www.manualweb.net/tutorial-html/" title="HTML">HTML</a> u otra. La URL será algo como lo siguiente:</p>
<pre>http://www.miservidor.com/datos.jsp?pagina=2</pre>
<p>Aunque no quiero entrar en detalle del código <a href="http://www.manualweb.net/tutorial-jsp/" title="JSP">JSP</a> os adjunto un pequeño extracto del código. De forma orientativa:</p>
<pre class="java" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #66cc66;">&lt;%</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://w3api.com/wiki/Java:String"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> provincias = <span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">&quot;Álava&quot;</span>,<span style="color: #ff0000;">&quot;Albacete&quot;</span>,<span style="color: #ff0000;">&quot;Alicante&quot;</span>,<span style="color: #ff0000;">&quot;Almería&quot;</span>,...,<span style="color: #ff0000;">&quot;Zamora&quot;</span>,<span style="color: #ff0000;">&quot;Zaragoza&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333;">int</span> pagina = <a href="http://w3api.com/wiki/Java:Integer"><span style="color: #aaaadd; font-weight: bold;">Integer</span></a>.<span style="color: #006600;">valueOf</span><span style="color: #66cc66;">&#40;</span>request.<span style="color: #006600;">getParameter</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;pagina&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">pagina=<span style="color: #66cc66;">&#40;</span>pagina-<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">out.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&amp;lt;ul&amp;gt;&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> x=<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">;</span>x<span style="color: #66cc66;">&lt;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">;</span>x++<span style="color: #66cc66;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	out.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff0000;">&lt;li&gt;&quot;</span> + provincias<span style="color: #66cc66;">&#91;</span>pagina+x<span style="color: #66cc66;">&#93;</span> + <span style="color: #ff0000;">&quot;&lt;/li&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #ff0000;">&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>	</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">out.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&amp;lt;/ul&amp;gt;&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #66cc66;">%&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li></ol></pre>
<p>Comentándolo muy por encima, recupera el valor del parámetro utilizando el método <a href="http://www.w3api.com/wiki/Java:ServletRequest.getParameter()" title="getParameter()">.getParameter()</a> y lo utiliza para acceder a un array de String. A partir de ese elemento del array devuelve 10 elementos en una lista <a href="http://www.manualweb.net/tutorial-html/" title="HTML">HTML</a> utilizando las etiquetas <a href="http://www.w3api.com/wiki/HTML:UL" title="UL">UL</a> y <a href="http://www.w3api.com/wiki/HTML:LI" title="LI">LI</a>.</p>
<p>Pero centrémonos en la parte cliente. Lo primero será definir la página. La página tendrá una capa <a href="http://www.w3api.com/wiki/HTML:DIV" title="DIV">DIV</a> donde iremos mostrando el contenido. Es importante darle un <a href="http://www.w3api.com/wiki/HTML:Id" title="ID">ID</a> a la capa, ya que nuestro código <a href="http://www.manualweb.net/tutorial-javascript/" title="JavaScript">JavaScript</a> accederá a ella para ir modificando el contenido de forma asíncrona.</p>
<p>Debajo de la capa pondremos 5 enlaces que llamen a una función <a href="http://www.manualweb.net/tutorial-javascript/" title="JavaScript">JavaScript</a> paginar. Esta función será la que realice la petición <a href="http://www.manualweb.net/tutorial-ajax/" title="AJAX">AJAX</a> y cargue el contenido en la capa <a href="http://www.w3api.com/wiki/HTML:DIV" title="DIV">DIV</a>.</p>
<p>Veamos este código:</p>
<pre class="html4strict" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:DIV"><span style="color: #000000; font-weight: bold;">div</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;datos&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:DIV"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:A"><span style="color: #000000; font-weight: bold;">a</span></a> <a href="http://w3api.com/wiki/HTML:href"><span style="color: #000066;">href</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <a href="http://w3api.com/wiki/HTML:onclick"><span style="color: #000066;">onclick</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;paginar(1);&quot;</span> <a href="http://w3api.com/wiki/HTML:title"><span style="color: #000066;">title</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;paginar&quot;</span>&gt;</span>1<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:A"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span> |</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:A"><span style="color: #000000; font-weight: bold;">a</span></a> <a href="http://w3api.com/wiki/HTML:href"><span style="color: #000066;">href</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <a href="http://w3api.com/wiki/HTML:onclick"><span style="color: #000066;">onclick</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;paginar(2);&quot;</span> <a href="http://w3api.com/wiki/HTML:title"><span style="color: #000066;">title</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;paginar&quot;</span>&gt;</span>2<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:A"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span> |</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:A"><span style="color: #000000; font-weight: bold;">a</span></a> <a href="http://w3api.com/wiki/HTML:href"><span style="color: #000066;">href</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <a href="http://w3api.com/wiki/HTML:onclick"><span style="color: #000066;">onclick</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;paginar(3);&quot;</span> <a href="http://w3api.com/wiki/HTML:title"><span style="color: #000066;">title</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;paginar&quot;</span>&gt;</span>3<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:A"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span> |</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:A"><span style="color: #000000; font-weight: bold;">a</span></a> <a href="http://w3api.com/wiki/HTML:href"><span style="color: #000066;">href</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <a href="http://w3api.com/wiki/HTML:onclick"><span style="color: #000066;">onclick</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;paginar(4);&quot;</span> <a href="http://w3api.com/wiki/HTML:title"><span style="color: #000066;">title</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;paginar&quot;</span>&gt;</span>4<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:A"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span> |</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:A"><span style="color: #000000; font-weight: bold;">a</span></a> <a href="http://w3api.com/wiki/HTML:href"><span style="color: #000066;">href</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <a href="http://w3api.com/wiki/HTML:onclick"><span style="color: #000066;">onclick</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;paginar(5);&quot;</span> <a href="http://w3api.com/wiki/HTML:title"><span style="color: #000066;">title</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;paginar&quot;</span>&gt;</span>5<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:A"><span style="color: #000000; font-weight: bold;">a</span></a>&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li></ol></pre>
<p>La función <a href="http://www.manualweb.net/tutorial-javascript/" title="JavaScript">JavaScript</a> paginar será la que realice todo el trabajo. Como vemos esta función recibe un parámetro que indica el número de página sobre el que queremos posicionarnos.</p>
<pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #003366; font-weight: bold;">function</span> paginar<span style="color: #009900;">&#40;</span>pagina<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>...<span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li></ol></pre>
<p>Lo primero que tiene que realizar esta función es cargar el objeto que nos permita realizar las peticiones asíncronas a modo <a href="http://www.manualweb.net/tutorial-ajax/" title="AJAX">AJAX</a>. Este objeto es <a href="http://www.w3api.com/wiki/Javascript:XMLHttpRequest" title="XMLHttpRequest">XMLHttpRequest</a>.</p>
<p>Aunque el objeto <a href="http://www.w3api.com/wiki/Javascript:XMLHttpRequest" title="XMLHttpRequest">XMLHttpRequest</a> es un objeto ya <a href="http://www.w3.org/TR/XMLHttpRequest/" title="estandarizado y definido por la W3C">estandarizado y definido por la W3C</a> hay ciertos navegadores (como el Internet Explorer) que siguen sin implementarlo. En su defecto utilizan el objeto Microsoft.XMLHTTP. Este viene a hacer lo mismo, o algo parecido, pero con otro nombre.</p>
<p>Es por ello que la instancia del objeto <a href="http://www.w3api.com/wiki/Javascript:XMLHttpRequest" title="XMLHttpRequest">XMLHttpRequest</a> se complica un poco. Quedaría de la siguiente manera:</p>
<pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #006600; font-style: italic;">// Llama objeto XMLHttpRequest</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">XMLHttpRequest</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   req <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>    </div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #006600; font-style: italic;">// Si no funciona intenta utiliar el objeto IE/Windows ActiveX</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">ActiveXObject</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   req <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Microsoft.XMLHTTP&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li></ol></pre>
<p>La variable que tiene la instancia es req. Esta variable será la que represente la conexión con el servicio de datos</p>
<p>El siguiente paso será establecer la conexión. Para ello seguimos tres pasos:</p>
<p>Primero indicamos que función <a href="http://www.manualweb.net/tutorial-javascript/" title="JavaScript">JavaScript</a> es la que va a procesar la respuesta del servidor. Esto lo hacemos mediante el evento <a href="http://www.w3api.com/wiki/Javascript:XMLHttpRequest.onreadystatechange" title="onreadystatechange">.onreadystatechange</a> de la petición. En nuestro caso será la función <a href="http://www.manualweb.net/tutorial-javascript/" title="JavaScript">JavaScript</a> "procesarRespuesta"</p>
<pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">req.<span style="color: #660066;">onreadystatechange</span> <span style="color: #339933;">=</span> procesarRespuesta<span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li></ol></pre>
<p>Segundo indicamos la URL a la cual queremos realizar la petición. Para componer la URL concatenamos la URL del servicio de datos con el número de página recibido como parámetro.</p>
<pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">url <span style="color: #339933;">=</span> <span style="color: #3366CC;">'http://www.miservidor.com/datos.jsp?pagina='</span> <span style="color: #339933;">+</span> pagina<span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">req.<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>url<span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li></ol></pre>
<p>El método <a href="http://www.w3api.com/wiki/Javascript:XMLHttpRequest.open()" title="open()">.open</a> es el que utilizamos para indicar la URL. Este tiene varios parámetros: tipo de petición (GET,POST o PUT), la URL y si queremos que sea síncrono -false- o asíncrono -false- como tercer parametro.</p>
<p>Tercero y último realizamos la petición. Para ello nos apoyamos en el método <a href="http://www.w3api.com/wiki/Javascript:XMLHttpRequest.send()" title="send()">.send()</a></p>
<pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">req.<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></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li></ol></pre>
<p>Veamos como es la función repaginar entera:</p>
<pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #003366; font-weight: bold;">function</span> paginar<span style="color: #009900;">&#40;</span>pagina<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> req <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #006600; font-style: italic;">// Llama objeto XMLHttpRequest</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">XMLHttpRequest</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   req <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>    </div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #006600; font-style: italic;">// Si no funciona intenta utiliar el objeto IE/Windows ActiveX</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">ActiveXObject</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   req <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Microsoft.XMLHTTP&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>req<span style="color: #339933;">!=</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   req.<span style="color: #660066;">onreadystatechange</span> <span style="color: #339933;">=</span> procesarRespuesta<span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   url <span style="color: #339933;">=</span> <span style="color: #3366CC;">'datos.jsp?pagina='</span> <span style="color: #339933;">+</span> pagina<span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   req.<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>url<span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   req.<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></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li></ol></pre>
<p>Ahora nos tenemos que centrar en la función <a href="http://www.manualweb.net/tutorial-javascript/" title="JavaScript">JavaScript</a> "procesarRespuesta". Esta función es la que recibirá los datos del servidor y los colocará en la capa.<br />
Los datos de la respuesta vienen en la propiedad .<a href="http://www.w3api.com/wiki/Javascript:XMLHttpRequest.responseText" title="responseText">responseText</a> de la petición (es decir, del objeto req). Es por ello que simplemente tenemos que pegarlos en la capa.</p>
<pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #003366; font-weight: bold;">function</span> procesarRespuesta<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	contenido <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'datos'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	contenido.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;Cargando los datos...&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>req.<span style="color: #660066;">readyState</span><span style="color: #339933;">==</span><span style="color: #CC0000;">4</span> <span style="color: #339933;">&amp;&amp;</span> req.<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></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   		<span style="color: #006600; font-style: italic;">//mostrar resultados en esta capa</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   		contenido.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> req.<span style="color: #660066;">responseText</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">  <span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li></ol></pre>
<p>Para poder poner los datos en la capa DIV tenemos que haber accedido a ella mediante su ID y la función .getElementById(). Para modificar el contenido de una capa nos apoyamos en la propiedad .innerHTML. Esta propiedad será sobre la que dejemos el contenido de <a href="http://www.w3api.com/wiki/Javascript:XMLHttpRequest.responseText" title="responseText">responseText</a>.</p>
<p>Y ya está. Con esto hemos construido una repaginación de datos con <a href="http://www.manualweb.net/tutorial-ajax/" title="AJAX">AJAX</a> de una forma muy sencilla.</p>
<blockquote><p>Como último hay que destacar que tanto el archivo cliente como el servicio de datos tienen que estar en el mismo dominio. Debido a las políticas de seguridad de JavaScript.</p></blockquote>
<p><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/jquery/peticiones-ajax-con-jquery/" rel="bookmark" title="Enero 6, 2010">Peticiones AJAX con jQuery</a></li>
<li><a href="http://lineadecodigo.com/ajax/validar-usuario-usando-ajax/" rel="bookmark" title="Marzo 27, 2008">Validar usuario usando AJAX</a></li>
<li><a href="http://lineadecodigo.com/jquery/repaginar-con-jquery-y-ajax/" rel="bookmark" title="Febrero 1, 2010">Repaginar con jQuery y AJAX</a></li>
<li><a href="http://lineadecodigo.com/ajax/obtener-cabeceras-con-xmlhttprequest/" rel="bookmark" title="Marzo 24, 2008">Obtener cabeceras con XMLHttpRequest</a></li>
<li><a href="http://lineadecodigo.com/jquery/cargar-contenido-con-el-scroll-usando-jquery/" rel="bookmark" title="Mayo 24, 2010">Cargar contenido con el scroll usando jQuery</a></li>
</ul>
<p><!-- Similar Posts took 6.351 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_1852()',1000); }); </script><script type="text/javascript"> function loadGoogle1_1852(){ jQuery(document).ready(function($) { $('.dd-google1-1852').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/ajax/repaginar-datos-con-ajax/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Validar usuario usando AJAX</title>
		<link>http://lineadecodigo.com/ajax/validar-usuario-usando-ajax/</link>
		<comments>http://lineadecodigo.com/ajax/validar-usuario-usando-ajax/#comments</comments>
		<pubDate>Thu, 27 Mar 2008 09:00:03 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[AJAX]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/2008/03/27/validar-usuario-usando-ajax/</guid>
		<description><![CDATA[AJAX podemos verlo como un paradigma de programación Web. Resumiéndolo podemos decir que permite la recarga de datos de la página sin necesidad de una recarga total de la misma. No debemos de tomarnos dicho paradigma como la solución a todos nuestros problemas de rendimiento. Sobre todo porque existen ciertos escenarios donde AJAX complica el [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-1220'></div><g:plusone size='medium' href='http://lineadecodigo.com/ajax/validar-usuario-usando-ajax/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fajax%2Fvalidar-usuario-usando-ajax%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/ajax/validar-usuario-usando-ajax/" data-count="horizontal" data-text="Validar usuario usando AJAX" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>AJAX podemos verlo como un paradigma de programación Web. Resumiéndolo podemos decir que permite la recarga de datos de la página sin necesidad de una recarga total de la misma. No debemos de tomarnos dicho paradigma como la solución a todos nuestros problemas de rendimiento. Sobre todo porque existen ciertos escenarios donde AJAX complica el diseño de una manera desmesurada.</p>
<p>Si bien, en ciertas ocasiones puede ser algo muy útil. Uno de los ejemplos prácticos es la validación de los datos del formulario. Cuando vamos a recuperar información del usuario podemos utilizar JavaScript de una forma muy potente para validar la información introducida. Por ejemplo podemos validar los tamaños del texto introducido, si cumple algún patrón, si son números o fechas validar rangos y límites,...</p>
<p>Pero todo tiene un límite. Y el límite de las validaciones del cliente es cuando queremos validar lógica de negocio. Me explico, podemos pedirle al usuario que tecleé su usuario y querer validar si existe dicho usuario en nuestra base de datos. Sería algo poco sensato el tener descargado en el cliente el listado entero de usuarios para saber si el dato introducido es correcto o no.</p>
<p>Es en estos casos cuando el paradigma AJAX nos da una gran potencia ya que podemos ir de forma asíncrona al servidor de negocio y validar si existe el dato introducido. De tal manera podemos avisar al usuario de forma rápida si su nombre es válido o no.</p>
<p><span id="more-1220"></span>En este ejemplo vamos a ver cómo usar el paradigma AJAX para validar si el usuario introducido por pantalla ya le tenemos dado de alta en nuestras bases de datos. Algo muy útil en un formulario de alta de usuarios.</p>
<h3>Creando el formulario y la capa oculta</h3>
<p>Lo primero que tenemos que hacer es crear la página con el formulario. Tarea simple. ¿Quién no conoce el uso de la etiqueta FORM?</p>
<pre class="html4strict" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:FORM"><span style="color: #000000; font-weight: bold;">form</span></a> <a href="http://w3api.com/wiki/HTML:name"><span style="color: #000066;">name</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;form1&quot;</span> <a href="http://w3api.com/wiki/HTML:method"><span style="color: #000066;">method</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span> <a href="http://w3api.com/wiki/HTML:action"><span style="color: #000066;">action</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">  <span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a> <a href="http://w3api.com/wiki/HTML:for"><span style="color: #000066;">for</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;usuario&quot;</span>&gt;</span>Usuario:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:LABEL"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span> </div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:INPUT"><span style="color: #000000; font-weight: bold;">input</span></a> <a href="http://w3api.com/wiki/HTML:type"><span style="color: #000066;">type</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;usuario&quot;</span>&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:INPUT"><span style="color: #000000; font-weight: bold;">input</span></a> <a href="http://w3api.com/wiki/HTML:type"><span style="color: #000066;">type</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <a href="http://w3api.com/wiki/HTML:name"><span style="color: #000066;">name</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Submit&quot;</span> <a href="http://w3api.com/wiki/HTML:value"><span style="color: #000066;">value</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Enviar&quot;</span>&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:INPUT"><span style="color: #000000; font-weight: bold;">input</span></a> <a href="http://w3api.com/wiki/HTML:type"><span style="color: #000066;">type</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;reset&quot;</span> <a href="http://w3api.com/wiki/HTML:name"><span style="color: #000066;">name</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Submit2&quot;</span> <a href="http://w3api.com/wiki/HTML:value"><span style="color: #000066;">value</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Borrar&quot;</span>&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:FORM"><span style="color: #000000; font-weight: bold;">form</span></a>&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li></ol></pre>
<p>El comportamiento que vamos a dar a nuestro formulario es que una vez el usuario haya introducido su usuario vayamos a validarlo al servidor. Si el servidor me dice que ya existe el usuario, entonces deberemos de mostrarle al usuario una ventana diciéndole que ya existe el usuario en la base de datos.</p>
<p>Es por ello que necesitamos dos cosas más en nuestra página web. La primera es capturar el evento onChange del campo de texto del usuario. Es decir, una vez que el usuario tecleé el usuario y vaya a otro campo realizaremos la validación.</p>
<pre class="html4strict" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:INPUT"><span style="color: #000000; font-weight: bold;">input</span></a> <a href="http://w3api.com/wiki/HTML:type"><span style="color: #000066;">type</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;usuario&quot;</span> <a href="http://w3api.com/wiki/HTML:onchange"><span style="color: #000066;">onChange</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;return autentica();&quot;</span>&gt;</span></div></li></ol></pre>
<p>En el código que acabamos de poner llamaremos a la función JavaScript autentica() que será la que realice la validación asíncrona.</p>
<p>La segunda necesidad es la de tener una capa, oculta al principio, donde se le diga al usuario que su usuario ya está ocupado. Dicha capa la mostraremos si la respuesta del servidor es que si está ocupado y la ocultaremos nuevamente si la validación da un resultado positivo.</p>
<pre class="html4strict" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<a href="http://w3api.com/wiki/HTML:SPAN"><span style="color: #000000; font-weight: bold;">span</span></a> <a href="http://w3api.com/wiki/HTML:id"><span style="color: #000066;">id</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;error&quot;</span> <a href="http://w3api.com/wiki/HTML:style"><span style="color: #000066;">style</span></a><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;font-family: Verdana, Arial,</span></span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;"><span style="color: #ff0000;">   Helvetica, sans-serif; font-size: 12pt;color: #CC3300;</span></span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;"><span style="color: #ff0000;">  position:relative;visibility:hidden;&quot;</span>&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">usuario Ocupado ¡¡¡</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://w3api.com/wiki/HTML:SPAN"><span style="color: #000000; font-weight: bold;">span</span></a>&gt;</span></div></li></ol></pre>
<h3>Función Autentica</h3>
<p>Como hemos indicado en el párrafo anterior, la función autentica() será la que realice la petición asíncrona al servidor.</p>
<p>Dentro de la función lo que haremos serán tres cosas:</p>
<ol>
<li>Recuperar el valor del usuario introducido por el usuario.</li>
<li>Montar la url del servidor donde el valor del usuario irá como parámetro.</li>
<li>Llamar a la función leer_doc(url) que es la que se encarga únicamente de realizar la petición a la URL indicada como parámetro.</li>
</ol>
<pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #003366; font-weight: bold;">function</span> autentica<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> usuario <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;usuario&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> url <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;/samples/existeusuario.php?usuario=&quot;</span> <span style="color: #339933;">+</span> usuario<span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> leer_doc<span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div></li></ol></pre>
<h3>Petición XMLHttpRequest</h3>
<p>Para realizar la llamada al servidor vamos a crear una variable request que será la que en toda la vida del programa JavaScript mantenga la referencia a la petición.</p>
<pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #003366; font-weight: bold;">var</span> req<span style="color: #339933;">;</span></div></li></ol></pre>
<p>Dicha variable será la que dentro de la función leer_doc(url) realice la conexión mediante el objeto XMLHttpRequest.</p>
<p>El objeto XMLHttpRequest tiene dos formas de llamarse dependiendo del navegador en el que nos encontremos (que raro). Si existe el objeto como objeto del navegador bastará con realizar un new sobre el mismo, sino tendremos que instanciarlo como un ActiveX para los navegadores Internet Explorer (versiones 5 y 6). Quedándonos el siguiente código:</p>
<pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">XMLHttpRequest</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   req <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></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">ActiveXObject</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   req <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Microsoft.XMLHTTP&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div></li></ol></pre>
<h3>XMLHttpRequest y Callback</h3>
<p>El objeto XMLHttpRequest se maneja mediante callbacks. ¿Qué quiere decir esto? Que la respuesta del objeto será manipulada por la función que le indiquemos. Para ello tendremos que informar a la variable .onreadystatechange</p>
<p>En nuestro caso será la función procesarRespuesta la que analice la respuesta.</p>
<p>Lo que nos quedará será el realizar la petición a la URL previamente montada. Para ello utilizamos el método .open</p>
<pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>req<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   req.<span style="color: #660066;">onreadystatechange</span> <span style="color: #339933;">=</span> procesarRespuesta<span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   req.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'GET'</span><span style="color: #339933;">,</span> url<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   req.<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></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span> </div></li></ol></pre>
<h3>Analizando la respuesta: parsear el XML</h3>
<p>Una vez retornada la respuesta por el servidor los datos adjuntos a la misma irán a parar a nuestra función de callback procesarRespuesta().</p>
<p>En este caso, y como veremos en un momento, los datos devueltos por el servidor vienen en formato XML. Los datos los recuperaremos del atributo .responseXML del objeto XMLHttpRequest.</p>
<p>Como la respuesta viene en XML deberemos utilizar funciones del DOM para poder ver que valores tienen y actuar en consecuencia. En este caso la función .getElementsByTagName("tag").</p>
<p>Dentro del XML devuelto viene la etiqueta &lt;existe&gt; que tendrá un valor de "true" si el usuario enviado ya existe y un valor de "false" si el valor enviado no existe en la base de datos.</p>
<p>A si que en caso afirmativo pondremos la capa de error de la página a visible (el usuario existe) o la ocultaremos (si el usuario no existe)</p>
<pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #003366; font-weight: bold;">function</span> procesarRespuesta<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> respuesta <span style="color: #339933;">=</span> req.<span style="color: #660066;">responseXML</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #003366; font-weight: bold;">var</span> existe <span style="color: #339933;">=</span> respuesta.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'existe'</span><span style="color: #009900;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   .<span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">firstChild</span>.<span style="color: #660066;">data</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>existe<span style="color: #339933;">==</span><span style="color: #3366CC;">&quot;true&quot;</span><span style="color: #009900;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;error&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">visibility</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;visible&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #000066; font-weight: bold;">else</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;error&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">visibility</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;hidden&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div></li></ol></pre>
<h3>Página PHP, ¿Nuestro WebService?</h3>
<p>En esto del AJAX pasa a ser algo de vital importancia el uso de servicios web, ya sean WebServices, páginas con script de servidor, CGI o similares.</p>
<p>En nuestro ejemplo la llamada se hace a la http://lineadecodigo.com/samples/existeusuario.php?usuario=miusuario</p>
<p>Es decir, que estamos usando una página PHP.</p>
<p>Dicha página PHP es muy sencilla, y aunque lo suyo sería que fuese a una base de datos, lo que he hecho ha sido devolver un XML estático. Dicho XML solo varía cuando se meta un usuario en concreto ("victor").</p>
<pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000; font-weight: bold;">&lt;?php</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   <span style="color: #0000ff;">$usuario</span> = <span style="color: #0000ff;">$_GET</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;usuario&quot;</span><span style="color: #66cc66;">&#93;</span>;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   <a href="http://www.php.net/header"><span style="color: #000066;">header</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Content-type: text/xml'</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$usuario</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff0000;">&quot;victor&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">     <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&lt;existe&gt;true&lt;/existe&gt;&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">     <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&lt;existe&gt;false&lt;/existe&gt;&quot;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   <span style="color: #66cc66;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000; font-weight: bold;">?&gt;</span></div></li></ol></pre>
<p>Ahora que podemos complicar este código cuanto queramos. Acceder a una base de datos,...</p>
<p><a href='http://img.aulambra.com/wp-content/uploads/2008/03/existe-usuario.html' title='Validar usuario usando AJAX'>Visualizar el ejemplo</a><br />
|- <a href='http://img.aulambra.com/wp-content/uploads/2008/03/existeusuario.zip' title='Descargar Validar usuario usando AJAX'>Descargar el código</a><br />
|- <a href="http://code.google.com/p/lineadecodigo/source/browse/trunk/lineadecodigo_web/WebContent/scripting/ajax/ExisteUsuario" title="Descargar del SVN">Descargar del SVN</a><br />
|- <a href="http://code.google.com/p/lineadecodigo/issues/list" title="Reportar un error">Reportar un error del código</a><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/ajax/repaginar-datos-con-ajax/" rel="bookmark" title="Agosto 6, 2009">Repaginar datos con AJAX</a></li>
<li><a href="http://lineadecodigo.com/jquery/peticiones-ajax-con-jquery/" rel="bookmark" title="Enero 6, 2010">Peticiones AJAX con jQuery</a></li>
<li><a href="http://lineadecodigo.com/ajax/obtener-cabeceras-con-xmlhttprequest/" rel="bookmark" title="Marzo 24, 2008">Obtener cabeceras con XMLHttpRequest</a></li>
<li><a href="http://lineadecodigo.com/javascript/confirmar-datos-en-javascript/" rel="bookmark" title="Diciembre 8, 2006">Confirmar datos en JavaScript</a></li>
<li><a href="http://lineadecodigo.com/jquery/cargar-contenido-con-el-scroll-usando-jquery/" rel="bookmark" title="Mayo 24, 2010">Cargar contenido con el scroll usando jQuery</a></li>
</ul>
<p><!-- Similar Posts took 5.375 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_1220()',1000); }); </script><script type="text/javascript"> function loadGoogle1_1220(){ jQuery(document).ready(function($) { $('.dd-google1-1220').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/ajax/validar-usuario-usando-ajax/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Obtener cabeceras con XMLHttpRequest</title>
		<link>http://lineadecodigo.com/ajax/obtener-cabeceras-con-xmlhttprequest/</link>
		<comments>http://lineadecodigo.com/ajax/obtener-cabeceras-con-xmlhttprequest/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 09:00:07 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ActiveX]]></category>
		<category><![CDATA[getAllResponseHeaders]]></category>
		<category><![CDATA[getElementById]]></category>
		<category><![CDATA[getResponseHeader]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[Microsoft.XMLHTTP]]></category>
		<category><![CDATA[onreadystatechange]]></category>
		<category><![CDATA[open]]></category>
		<category><![CDATA[overrideMimeType]]></category>
		<category><![CDATA[readyState]]></category>
		<category><![CDATA[send]]></category>
		<category><![CDATA[status]]></category>
		<category><![CDATA[web2.0]]></category>
		<category><![CDATA[XMLHttpRequest]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/2008/03/24/obtener-cabeceras-con-xmlhttprequest/</guid>
		<description><![CDATA[Si tenemos que describir la Web 2.0 estoy seguro que no podríamos obviar la palabra AJAX. Y es que podríamos decir que la Web 2.0 se sustenta sobre un modelo tecnológico asíncrono, el cual, mediante peticiones/respuesta para regenerar parte de la página busca dar un efecto de mayor velocidad al usuario final. Al menos, mayor [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-1210'></div><g:plusone size='medium' href='http://lineadecodigo.com/ajax/obtener-cabeceras-con-xmlhttprequest/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fajax%2Fobtener-cabeceras-con-xmlhttprequest%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/ajax/obtener-cabeceras-con-xmlhttprequest/" data-count="horizontal" data-text="Obtener cabeceras con XMLHttpRequest" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p>Si tenemos que describir la Web 2.0 estoy seguro que no podríamos obviar la palabra AJAX. Y es que podríamos decir que la Web 2.0 se sustenta sobre un modelo tecnológico asíncrono, el cual, mediante peticiones/respuesta para regenerar parte de la página busca dar un efecto de mayor velocidad al usuario final. Al menos, mayor que la recarga entera de la página. "Pure AJAX".</p>
<p>Y si hablamos de AJAX tenemos que hablar del objeto XMLHttpRequest, sobre el cual nos apoyamos para realizar las peticiones asíncronas desde la página web.</p>
<p>Una de las posibilidades que nos ofrece este objeto es la de conocer la información de la cabecera http. Para ello tenemos los métodos .getAllResponseHeaders() o .getResponseHeader(etiqueta). El primero nos dará toda la información de la cabecera y el segundo nos permitirá ir a buscar un valor en concreto.</p>
<p><span id="more-1210"></span>Un ejemplo de esta respuesta sería el siguiente:</p>
<pre>Microsoft-IIS/5.0
Date: Sat, 10 Jun 2006 17:12:29 GMT
Content-Length: 43
Content-Type: text/xml
Cache-Control: private</pre>
<p>El uso de estas cabeceras puede ser de lo más variopinto y va desde la validación de las ultimas modificaciones del recurso para ver si es válido o no, control de la cache o del contenido de la respuesta,....</p>
<p>Para poder recuperar las cabeceras lo primero que tenemos que hacer es crear un objeto XMLHttpRequest. A la hora de cargar un objeto XMLHttpRequest lo podremos hacer de dos formas. Mediante el propio objeto XMLHttpRequest o bien mediante un ActiveX para mantener compatibilidad con IE5 e IE6.</p>
<pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">req <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #006600; font-style: italic;">// Llama objeto XMLHttpRequest</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">XMLHttpRequest</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   req <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></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>req.<span style="color: #660066;">overrideMimeType</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">     req.<span style="color: #660066;">overrideMimeType</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'text/xml'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   <span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #006600; font-style: italic;">// Si no funciona intenta utiliar el objeto IE/Windows ActiveX</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">ActiveXObject</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   req <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Microsoft.XMLHTTP&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div></li></ol></pre>
<p>Una vez que tenemos el objeto XMLHttpRequest instanciado deberemos de indicar cual es el método de callback, es decir, que método va a atender la respuesta. Esto lo hacemos mediante el atributo onreadystatechange. </p>
<p>Lo siguiente será llamar al método open, para indicarle los parámetros de conexión: método de envío, URL destino,...</p>
<blockquote><p>Recuerda que la URL destino del método open tiene que estar en tu mismo dominio. En caso contrario no podrás acceder al contenido de dicha URL.</p></blockquote>
<p>Por último llamaremos al método send. El cual realizará la conexión.   </p>
<pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>req<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   req.<span style="color: #660066;">onreadystatechange</span> <span style="color: #339933;">=</span> procesarRespuesta<span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   req.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'GET'</span><span style="color: #339933;">,</span> url<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   req.<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></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span> </div></li></ol></pre>
<p>Cuando procesemos la respuesta simplemente tendremos que llamar al método .getAllResponseHeaders() o .getResponseHeader(etiqueta)</p>
<p>Debemos de recordar que para procesar la respuesta es una buena práctica que la petición ha terminado</p>
<pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>req.<span style="color: #660066;">readyState</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span></div></li></ol></pre>
<p>Y que la respuesta del servidor ha sido un OK. Es decir, un código de status 200.</p>
<pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>req.<span style="color: #000066;">status</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">200</span><span style="color: #009900;">&#41;</span></div></li></ol></pre>
<p>Una vez hechas todas las validaciones y en nuestro caso vamos a volcar las cabeceras en un área de texto.</p>
<pre class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">sTexto <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;texto&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>req.<span style="color: #660066;">readyState</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   texto <span style="color: #339933;">=</span> texto <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;Respuesta Procesada...<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   texto <span style="color: #339933;">=</span> texto <span style="color: #339933;">+</span> req.<span style="color: #660066;">getAllResponseHeaders</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   texto <span style="color: #339933;">=</span> texto <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;Estado de la petición: &quot;</span> <span style="color: #339933;">+</span> req.<span style="color: #000066;">status</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">   document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;texto&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> texto<span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div></li></ol></pre>
<p><a href='http://img.aulambra.com/wp-content/uploads/2008/03/cabecerasxmlhttprequest.html' title='Cabeceras XMLHttpRequest'>Visualizar el ejemplo</a><br />
|- <a href='http://img.aulambra.com/wp-content/uploads/2008/03/cabecerasxmlhttprequest.zip' title='Descargar Cabeceras XMLHttpRequest'>Descargar el código</a><br />
|- <a href="http://code.google.com/p/lineadecodigo/source/browse/trunk/lineadecodigo_web/WebContent/scripting/ajax/CabecerasXMLHttpRequest.html" title="Descargar del SVN">Descargar del SVN</a><br />
|- <a href="http://code.google.com/p/lineadecodigo/issues/list" title="Reportar un error del código">Reportar un error del código</a><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/ajax/repaginar-datos-con-ajax/" rel="bookmark" title="Agosto 6, 2009">Repaginar datos con AJAX</a></li>
<li><a href="http://lineadecodigo.com/ajax/validar-usuario-usando-ajax/" rel="bookmark" title="Marzo 27, 2008">Validar usuario usando AJAX</a></li>
<li><a href="http://lineadecodigo.com/asp/borrar-registros-de-una-base-de-datos-con-ado/" rel="bookmark" title="Febrero 22, 2009">Borrar registros de una base de datos con ADO</a></li>
<li><a href="http://lineadecodigo.com/html/generar-un-documento-html-mediante-javascript/" rel="bookmark" title="Junio 28, 2007">Generar un documento HTML mediante JavaScript</a></li>
<li><a href="http://lineadecodigo.com/asp/responder-xml-en-asp/" rel="bookmark" title="Octubre 10, 2009">Responder XML en ASP</a></li>
</ul>
<p><!-- Similar Posts took 5.408 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_1210()',1000); }); </script><script type="text/javascript"> function loadGoogle1_1210(){ jQuery(document).ready(function($) { $('.dd-google1-1210').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/ajax/obtener-cabeceras-con-xmlhttprequest/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AJAX en la Plataforma IBM WebSphere</title>
		<link>http://lineadecodigo.com/noticias-web/ajax-en-la-plataforma-ibm-websphere/</link>
		<comments>http://lineadecodigo.com/noticias-web/ajax-en-la-plataforma-ibm-websphere/#comments</comments>
		<pubDate>Tue, 23 Jan 2007 11:00:01 +0000</pubDate>
		<dc:creator>Víctor Cuervo</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[DOJO]]></category>
		<category><![CDATA[Noticias Web]]></category>

		<guid isPermaLink="false">http://lineadecodigo.com/2007/01/23/ajax-en-la-plataforma-ibm-websphere/</guid>
		<description><![CDATA[IBM libera AJAX para la plataforma WebSphere junto con un "Early Access Program". En esta versión se incluye Dojo Toolkit 0.4.1 y 3 aplicaciones end-to-end que muestran como Dojo puede ser utilizado en aplicaciones J2EE sobre la plataforma WebSphere. Todas las características están empaquetadas para utilizar en el entorno Eclipse 3.2.1 de igual manera que [...]]]></description>
			<content:encoded><![CDATA[<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-google1-ajax-load dd-google1-401'></div><g:plusone size='medium' href='http://lineadecodigo.com/noticias-web/ajax-en-la-plataforma-ibm-websphere/'></g:plusone></div><div class='dd_button'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Flineadecodigo.com%2Fnoticias-web%2Fajax-en-la-plataforma-ibm-websphere%2F" send="false" show_faces="false"  layout="button_count" width="92"  ></fb:like></div><div class='dd_button'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://lineadecodigo.com/noticias-web/ajax-en-la-plataforma-ibm-websphere/" data-count="horizontal" data-text="AJAX en la Plataforma IBM WebSphere" data-via="" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div></div><div style='clear:both'></div></div><div style='clear:both'></div><p><a class="imagelink" href="http://www.ibm.com" title="IBM"><img id="image399" src="http://img.aulambra.com/wp-content/uploads/2007/01/ibm.gif" alt="IBM" style="float:right"/></a> IBM libera AJAX para la plataforma WebSphere junto con un "Early Access Program". En esta versión se incluye Dojo Toolkit 0.4.1 y 3 aplicaciones end-to-end que muestran como Dojo puede ser utilizado en aplicaciones J2EE sobre la plataforma WebSphere.</p>
<p><span id="more-401"></span>Todas las características están empaquetadas para utilizar en el entorno Eclipse 3.2.1 de igual manera que hay una distribución para desarrolladores no-Eclipse.</p>
<p>AJAX para la plataforma IBM WebSphere incluye:</p>
<ul>
<li>Toolkit Dojo</li>
<li>Librerias JSON4J</li>
<li>Web Pub Sub Bridge for AJAX</li>
<li>4 ejemplos</li>
</ul>
<p>Además podemos encontrar una version offline de la versión borrador del "DOJO Book".</p>
<p>Las plataformas de servidor soportadas son AIX®, HP-UX, Linux, Solaris, Windows, z/OS,... y dentro de la plataforma cliente Intenet Explorer 5.5/6 y Mozilla FireFox 1.5 (y superiores).</p>
<p><a href="https://www14.software.ibm.com/iwm/web/cc/earlyprograms/websphere/ibmajaxw/" title="Early Access Program de AJAX">Puedes informarte del "Early Access Program" de AJAX</a></p>
<p>Vía: <a href="http://ajaxian.com/archives/ajax-for-ibm-websphere-platform-early-program" title="Ajaxian">Ajaxian</a><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://lineadecodigo.com/java/ibm-java-sdk-6-beta/" rel="bookmark" title="Enero 22, 2007">IBM Java SDK 6 Beta</a></li>
<li><a href="http://lineadecodigo.com/noticias-web/2007-technology-of-the-year-awards/" rel="bookmark" title="Enero 3, 2007">2007 Technology of the year awards</a></li>
<li><a href="http://lineadecodigo.com/noticias-web/silverlight-10/" rel="bookmark" title="Septiembre 8, 2007">SilverLight 1.0</a></li>
<li><a href="http://lineadecodigo.com/noticias-web/netbeans-6-9/" rel="bookmark" title="Junio 16, 2010">Netbeans 6.9</a></li>
<li><a href="http://lineadecodigo.com/eventos/ajax-programming-with-passion/" rel="bookmark" title="Febrero 4, 2007">AJAX Programming (with Passion!)</a></li>
</ul>
<p><!-- Similar Posts took 5.002 ms --></p>
<script type="text/javascript"> jQuery(document).ready(function($) { window.setTimeout('loadGoogle1_401()',1000); }); </script><script type="text/javascript"> function loadGoogle1_401(){ jQuery(document).ready(function($) { $('.dd-google1-401').remove();$.getScript('https://apis.google.com/js/plusone.js'); }); }</script><!-- Social Buttons Generated by Digg Digg plugin v5.2.6,
    Author : Buffer, Inc
    Website : http://bufferapp.com/diggdigg -->]]></content:encoded>
			<wfw:commentRss>http://lineadecodigo.com/noticias-web/ajax-en-la-plataforma-ibm-websphere/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: lineadecodigo.com @ 2012-05-17 19:52:19 by W3 Total Cache -->
