Good morning friends.
I have the following code js in which I extract data from the database through ajax, and I get my data to my form through its id attribute.
$(".btnEditarTicket").click(function(){
var idTicket = $(this).attr("idTicket");
var datos = new FormData();
datos.append("idTicket",idTicket);
$.ajax({
url:"ajax/tickets.ajax.php",
method :"POST",
data:datos,
cache: false,
contentType: false,
processData: false,
dataType: "json",
success:function(respuesta){
console.log("respuesta", respuesta);
$("#IdeditarTitulo").val(respuesta["id"]);
$("#editarTitulo").val(respuesta["titulo"]);
$("#editarDescripcion").val(respuesta["descripcion"]);
$("#editarUserid").val(respuesta["user_id"]);
$("#editarProject").val(respuesta["project_id"]);
$("#editarProject").html(respuesta["project_id"]);
$("#editarCategory").val(respuesta["category_id"]);
$("#editarCategory").html(respuesta["category_id"]);
}
});
})
So far, it returns the data correctly now, what I want is that the value of $("#editarProject").val(respuesta["project_id"]);
and $("#editarCategory").val(respuesta["category_id"]);
can be taken as variables of php, which option could be used. Any suggestions would be appreciated.