title: Printing another page with data from a search via ajax connected to the PHP server
body: <p>I have this jQuery function:</p>
  
  <pre><code>function findProducts() {
      $.ajax({
          type: "POST",
          url: "code.php",
          data: {
              city: $(".city").val(),
              product: $("#product").val(),
          },
      }).done(function(data) {
          window.location.href = "results.html";
          var obj = JSON.parse(data);
          obj.forEach(function(index) {
              var tableBody = $("tbody");
              var row = $("&lt;tr&gt;");
  
              var columnImgName = $("&lt;td&gt;").addClass("img-name");
              var divImg = $("&lt;div&gt;").addClass("image");
              var image = $("&lt;img&gt;").addClass("image-product").attr("src", "img/no-image.png");
              var nameProduct = $("&lt;p&gt;").addClass("name-product").index[0]);
  
              var columnPrice = $("&lt;td&gt;").addClass("prico").index[1]);
  
              var rows = tableBody.append(row);
  
              rows.append(columnImgName).append(divImg).append(image);
              rows.append(columnImgName).append(nameProduct);
              rows.append(columnPrice);
          });
      });
  }
  </code></pre>
  
  <p>I'm trying to run a search on my database informing the city and the product. I'm making an ajax to the php code on my server that returns a JSON with the data I searched. I want to get that data that is returned on this JSON and go to another page where I will print a table with the informations I got. I tried this code but it isn't working, it just redirects to the other page but the table doesn't appear. The HTML code for the table is this:</p>
  
  <pre><code>        &lt;table&gt;
              &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;th&gt;Product&lt;/th&gt;
                      &lt;th&gt;Price&lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tbody&gt;
              &lt;/tbody&gt;
          &lt;/table&gt;
  </code></pre>