I have the following code that should bring a response from a PHP file but it does not return anything. The answer should print it in an input. Any suggestions? Thank you very much!
$('#servicio select').on('change', function() {
var servicioVal = $(this).val();
//petición ajax
$.ajax({
type: 'POST',
url: 'actionservrem.php',
dataType: 'html',
data: servicioVal,
async : false,
success: function(respuesta) {
preciounitario = respuesta;
},
});
var $previousInput = $(this).closest('tr').find('td:first input:text');
$previousInput.val(preciounitario);
});
actionservrem.php
<?php
include("includes/conexion.php");
$Servicio = $_POST["servicioVal"];
$resultPrecios = mysql_query("SELECT * FROM listasyservicios
WHERE id_listasyservicios = '$Servicio'");
while($row = mysql_fetch_array($resultPrecios)){
echo ''.$row["precioventa"].'';
}
?>