Open Brecht272727 opened 2 years ago
Hi, i using the latest version of MysqlDb.php I am using ajax with dataType 'json'. But i can't see the error message in console. See below for the ajax code i use:
if($_POST) { include('../lib/connection.php'); $cname = $_REQUEST['cname']; $street = $_REQUEST['street']; $postal = $_REQUEST['postal']; $city = $_REQUEST['city']; $country = $_REQUEST['country']; $phone = $_REQUEST['phone']; if(empty($cname)) { $cname = NULL; } $data = array( 'cname' => $cname, 'street' => $street, 'postal' => $postal, 'city' => $city, 'country' => $country, 'phone1' => $phone, 'status' => 1, 'created' => date('Y-m-d H:i:s') ); $db->insert('addresses', $data); if($db->getLastErrno() === 0) { $res = array('success' => true, 'message' => 'Leveringsadres toegevoegd'); } else { $res = array('error' => true, 'message' => 'Leveringsadres niet toegevoegd: '.$db->getLastError()); } echo json_encode($res); }
$.ajax({ type: 'POST', url: 'assets/ajax/save-deliveryform.php', dataType: 'json', cache: false, data: $('.deliveryForm').serialize(), success: function (data) { console.log(data); }, error: function (xhr, status, error) { console.log('An error occurred'); var err = eval("(" + xhr.responseText + ")"); console.log(err); } });
@avbdr or @ThingEngineer ? Any solution?
Hi, i using the latest version of MysqlDb.php I am using ajax with dataType 'json'. But i can't see the error message in console. See below for the ajax code i use: