I am working on a project for a crm(just to learn) and i have trouble with an ajax function.
<div class="dropdown">
<label>Name</label>
<select class="named" name ="named" id="named" onchange="userData('<?php echo $client['client_name']; ?>')">
<?php
$clients=mysqli_query($db->db,"SELECT client_name FROM clients");
foreach($clients as $client): ?>
<option value="<?= $client['client_name'];?>"><?= $client['client_name']; ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label>Location</label>
<input type="text" class="form-control" name="locationd" id="locationd"/>
and the ajax function
function userData(name){
alert('debug');
$.ajax({
type: 'POST',
dataType:'JSON',
url: 'adminAction.php',
data: 'action_type=clientdata&name='+name,
success:function(data){
alert('debug');
$('#locationd').val(data.client_location);
}
});
}
its a mysql generated dropdown and on change it should fill the location input with this clients location but it doesnt work.Apache returns no errors but i am kinda noob especially when it comes to debugging ajax calls(how the ** can i see what data it sends and receives ? :D).Thanks for your help in advance !! I post the adminaction.php code too
if($_POST['action_type'] == 'clientdata'){
$tblName = 'clients';
$conditions['where'] = array('client_name' =>$_POST['named']);
$conditions['return_type'] = 'single';
$client = $db->getRows($tblName,$conditions);
echo json_encode($client);
$tblName = 'clients_contact';
for anyone interested i fixed it like that
function userData(){
userData = $("#named").serialize()+'&action_type=clientdata';
$.ajax({
type: 'POST',
dataType:'JSON',
url: 'adminAction.php',
data: userData,
success:function(data){
$('#locationd').val(data.client_location);
}
});
}