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
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
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
Let him run and try it. Greetings
$(document).on('click', '.borrar', function (event) {
event.preventDefault();
$(this).closest('tr').remove();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<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>
<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>
<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>
<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>
<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>
</tr>
</table>
</body>
</html>
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