Reputation: 655
i have a drop-down select tag use for showing the data from my database i also use ajax request to fetch my data from database but the problem i encounter is that when i get the result it how on my error:function()
admin_table.on('click', '#pay', function() {
$tr = $(this).closest('tr');
var data = admin_table.row($tr).data();
$(document).on('click', '#dr_1', function(){
$.ajax({
type:'POST',
url:'../functions/ajax/get_delivery_receipts.php',
data:{
id: data['user_id']
},
dataType:'JSON',
sucess: function(data){
console.log(data);
},
error: function(err){
console.log(err.responseText);
}
});
});
});
this is my function.. reason for that structure is the '#pay'
is a button from the table.. and '#dr_1'
is inside the modal that pop up when the 1st id is a click.
if (isset($_POST)) {
$id = $_POST['id'];
$res = $db->dr($id);
echo json_encode($res);
}
and this is inside the ajax request.
public function dr($id)
{
$sql="SELECT * FROM tbl_delivery WHERE user_id = '$id'";
var_dump($sql);
$stmt = $this->dbh->prepare($sql);
$stmt->execute();
$data = array();
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
$data[] = $row;
}
return $data;
}
and this is my query
Upvotes: 1
Views: 66
Reputation: 30893
error
Type: Function( jqXHR jqXHR, String textStatus, String errorThrown )
Would advise:
$(document).on('click', '#dr_1', function(){
$.ajax({
type: 'POST',
url: '../functions/ajax/get_delivery_receipts.php',
data: {
id: data['user_id']
},
dataType: 'JSON',
success: function(data, status, jqx){
console.log(data, staus, jqx);
},
error: function(jqx, status, err){
console.log(jqx, status, err);
}
});
});
I suspect that sucess
was the issue. It's success
.
Upvotes: 1