How to reload AJAX result without losing its value?


When I show a result with AJAX, how can I do so with a click button to update that result (not the page)? because if I do it with a reload with JAVASCRIPT, I reload the page and lose the result I got from AJAX

asked by Ivxn 16.06.2016 в 20:20

3 answers


I imagine that you should have an event onclick and send a specific data to a function something like this:

<input type="button" onclick="nombreFuncion(dato); return false;" >  

to avoid recharging the entire page, load the result thrown at you by the

answered by 16.06.2016 / 20:42

Let him run and try it. Greetings

$(document).on('click', '.borrar', function (event) {
<script src=""></script>
   <!DOCTYPE html>
<script src=""></script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <table border="1">
<tr id="fila0">
  <td>Columna 1.1</td>
  <td>Columna 1.2</td>
  <td>Columna 1.3</td>
  <td>Columna 1.4</td>
  <td>Columna 1.5</td>
  <td>Columna 1.6</td>
  <td><input type="button" class="borrar" value="Eliminar" /></td>
<tr id="fila1">
  <td>Columna 2.1</td>
  <td>Columna 2.2</td>
  <td>Columna 2.3</td>
  <td>Columna 2.4</td>
  <td>Columna 2.5</td>
  <td>Columna 2.6</td>
  <td><input type="button" class="borrar" value="Eliminar" /></td>
<tr id="fila2">
  <td>Columna 3.1</td>
  <td>Columna 3.2</td>
  <td>Columna 3.3</td>
  <td>Columna 3.4</td>
  <td>Columna 3.5</td>
  <td>Columna 3.6</td>
  <td><input type="button" class="borrar" value="Eliminar" /></td>
<tr id="fila3">
  <td>Columna 4.1</td>
  <td>Columna 4.2</td>
  <td>Columna 4.3</td>
  <td>Columna 4.4</td>
  <td>Columna 4.5</td>
  <td>Columna 4.6</td>
  <td><input type="button" class="borrar" value="Eliminar" /></td>
<tr id="fila4">
  <td>Columna 5.1</td>
  <td>Columna 5.2</td>
  <td>Columna 5.3</td>
  <td>Columna 5.4</td>
  <td>Columna 5.5</td>
  <td>Columna 5.6</td>
  <td><input type="button" class="borrar" value="Eliminar" /></td>
answered by 04.01.2017 в 16:32

If you are using some kind of input, you could add a function in js

function refresh() {
        var dato1 = String(document.getElementById("dondeobtienevalor").value);
        document.getElementById("dondesemostrara").value = (dato1);

without forgetting to add (onkeyup or onclick) = "refresh ();" to your element

answered by 16.06.2016 в 20:33