Very Good. I describe my problem to you
I have a table which contains a button with a value = Id of a contact (The Id varies according to the row in which we are located). It should be noted that all this is inside a form called frm_ContactosLista
What I want to do is send that value of the selected button by means of an ajax request and receive it in a php document to process it.
The code of the application is as follows
$("button[name='btn_Mcontactos']").click(function(){
var valor = $(this).val();
var url = "./webservice/llenarcontactos.php";
$.ajax({
type:"POST",
url: url,
data: $("#frm_ContactosLista").serialize(),
success: function(data){
$("#resultado").html(data);
}
});
return false;
});
the HTML code of the form
<form class='form form-horizontal validate-form' style='margin-bottom: 0;' method="post" id="frm_ContactosLista">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#Modal_Contactos" data-whatever="@mdo">+ Nuevo Contacto</button>
<!-- tabla -->
<div class="" id=resultado>
<div class='row-fluid'>
<div class='box-content box-no-padding'>
<div class='responsive-table'>
<div class='scrollable-area'>
<table class='data-table table table-bordered table-striped' data-pagination-records='25' style='padding-left:3px;'>
<thead>
<tr>
<th style="width:55px">
Editar
</th>
<th>
ID
</th>
<th>
Nombre
</th>
<th>
Titulo
</th>
<th>
compania
</th>
<th>
Telefono
</th>
<th>
Email
</th>
</tr>
</thead>
{{if ListaContactos}}
<tbody>
{{foreach ListaContactos}}
<tr>
<td>
<button type="button" class="btn btnimg" name="btn_Mcontactos" id="btn_Mcontactos" value="{{contactoId}}">
<img src="public/img/carpeta.png" alt="Ver" style="height:25px; width:25px;" />
</button>
</td>
<td> {{contactoId}}</td>
<td> {{nombre}}</td>
<td> {{titulo}}</td>
<td> {{compania}}</td>
<td> {{telefono}}</td>
<td> {{email}}</td>
</tr>
{{endfor ListaContactos}}
</tbody>
{{endif ListaContactos}}
</table>
</div>
</div>
</div>
</div>
</div>
<br><br><br>
</form>
and this is the file code fillcontactos.php where you should receive the code
<?php
require_once("../api/callapi.php");
echo "<script>alert('Aqui deberia mostrar el codigo');</script>";
?>