Uncaught TypeError: Cannot read properties of undefined (reading 'data')
at Object.success (websiteaccess:1704:42)
at c (vendor.bundle.base.js:11757:56)
at Object.fireWith as resolveWith
at l (vendor.bundle.base.js:13594:415)
at XMLHttpRequest. (vendor.bundle.base.js:13682:235)
Problem
success: function(data) {
console.log('update ho gaya successfully');
// adding alert messages
console.log(html.data);
// adding alert messages for success and exist data validation open
var html = '';
if (data.success) {
html = '<div class="alert alert-success">' + data.message + '</div>';
$('#form_result').html(html);
setTimeout(function() {
$('#formModal').modal('hide');
$('#WebAccessTable').DataTable().ajax.reload();
}, 2000);
in laravel
Log::info($Decrypted);
Log::info($Decrypted1);
Log::info($Decrypted2);
Log::info($Decrypted3);
Log::info($Decrypted4);
Log::info($Decrypted5);
Log::info($Decrypted6);
$data = [
'website' => $Decrypted, 'username' => $Decrypted2, 'email' => $Decrypted1,'password' => $Decrypted3,'pro_name' => $Decrypted4,'pro_engg' => $Decrypted5,'type_task' => $Decrypted6
];
return response()->json($data);
Solution
const parsed = JSON.parse(JSON.stringify({data}))
Full code
success: function(data) {
console.log('update ho gaya successfully');
// adding alert messages
const parsed = JSON.parse(JSON.stringify({data}));
console.log(parsed);
// adding alert messages for success and exist data validation open
var html = '';
if (data.success) {
html = '<div class="alert alert-success">' + data.message + '</div>';
$('#form_result').html(html);
setTimeout(function() {
$('#formModal').modal('hide');
$('#WebAccessTable').DataTable().ajax.reload();
}, 2000);
} else {
html = '<div class="alert alert-danger">' + data.message + '</div>';
$('#form_result').html(html);
}
// adding alert messages for success and exist data validation close
},
// message alert close
error: function(data) {
console.log('Error:', data);
// this function for hide with id #formModel
console.log('update function kamm nahi kr rha hai');
}
});
Top comments (0)