title: How to transfer this code with JQuery Ajax?
body: <p>Hope you can help me, I recently was told it would suit me best was to use Ajax with JQuery.
  The trouble is that this code programmed it long ago and following tutorials.
  I tried to pass the JQuery format but does not work in any way, do not know if some kind soul can guide me how to do it.</p>
  
  <p>The code is as follows:</p>
  
  <p>These functions define three parameters and sends them to another function called "get_ajax":</p>
  
  <pre><code>function resultado(contenido){
      var url='ajax/buscar.php?'+ contenido +'';// Get content
      var capa='resultado';
      var metodo='get';
      get_ajax(url,capa,metodo);
  }
  function paginas(contenido){
      var url='ajax/paginar.php?'+ contenido +'';// Get pages
      var capa='paginas';
      var metodo='get';
      get_ajax(url,capa,metodo);
  }
  </code></pre>
  
  <p>Then created the Ajax object:</p>
  
  <pre><code>function creaAjax(){
      var objetoAjax=false;
      try{objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");}
      catch(e){try {objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");} 
      catch (E){objetoAjax = false;}}
      if(!objetoAjax &amp;&amp; typeof XMLHttpRequest!='undefined') {
          objetoAjax = new XMLHttpRequest();}
      return objetoAjax;
  }
  </code></pre>
  
  <p>And finally defined "get_ajax" function with the variables defined in the "result" functions and "pages":</p>
  
  <pre><code>function get_ajax(url,capa,metodo){ 
      var ajax=creaAjax();
      var capaContenedora = document.getElementById(capa);
      if (metodo.toUpperCase()=='GET'){
          ajax.open ('GET', url, true);
          ajax.onreadystatechange = function() {
              if (ajax.readyState==1){
                  capaContenedora.innerHTML= "&lt;center&gt;&lt;img src=\"imagenes/down.gif\" /&gt;&lt;br&gt;&lt;font color='000000'&gt;&lt;b&gt;Loading...&lt;/b&gt;&lt;/font&gt;&lt;/center&gt;";
              } else if (ajax.readyState==4){ 
                  if(ajax.status==200){               
                      document.getElementById(capa).innerHTML=ajax.responseText; 
                  }else if(ajax.status==404){
                      capaContenedora.innerHTML = "&lt;CENTER&gt;&lt;H2&gt;&lt;B&gt;ERROR 404&lt;/B&gt;&lt;/H2&gt;0 RESULTS&lt;/CENTER&gt;";
                  } else {
                      capaContenedora.innerHTML = "Error: ".ajax.status;
                  }
              } // ****
          }
          ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
          ajax.send(null);
          return
      }
  }
  </code></pre>
  
  <p>The results of carrying on a "div" calling a javascript:</p>
  
  <pre><code>&lt;div class="table-responsive"&gt;
      &lt;div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" name="resultado" id="resultado"&gt;
          &lt;script type="text/javascript"&gt;
              resultado('q=&lt;?=$q?&gt;&amp;p=&lt;?=$p?&gt;');
          &lt;/script&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>But I think this last one is the least.
  I've been trying to change the "get_ajax" function to make it to corde a JQuery syntax pero it does not work.</p>
  
  <p>Thanks in advance.</p>
  
  <p>Edit:
  I tried changing the "get ajax" function, I know that the code you are totally wrong, but I have almost no experience with JQuery, I read the manual and know that for each state there is a different role, but this time I wanted to test directly with "success ".</p>
  
  <pre><code>function get_ajax(url,capa,metodo){
      $(document).ready(function(){
          $('#resultado').hide();
          $('#form').submit(function(evento){
              $('#resultado').hide();        
              evento.preventDefault();
              var datos_formulario = $(this).serialize();        
              $.ajax({
                  url: url,
                  data: datos_formulario, //I don't know
                  type: metodo,
                  dataType: 'json',
                  success: function(response){
                      $(capa).html(response);
                  }
              });
  
          });
      });
  }
  </code></pre>