I use the following Ajax call to fetch translations from a db.
The call itself works and returns the below result.
Can someone tell me how I can access the values from the array in the Ajax result so that I can assign them to my variables ? I either get an error or empty variables and couldn't find a way to make this work (I am new to arrays).
Note: The id in this case is a unique identifier so the Ajax call always returns only one row.
Ajax call:
$.ajax({
type: 'POST',
url: 'fetchTrans.php',
data: {
transId: transId
},
success: function(result){
var transDE = ''; // should be result['de']
var transEN = ''; // should be result['en']
var transDA = ''; // should be result['da']
var transES = ''; // should be result['es']
var transFR = ''; // should be result['fr']
var updateDate = ''; // should be result['updateDate']
$('#transId').val(transId);
$('#langDE').val(transDE);
$('#langEN').val(transEN);
$('#langDA').val(transDA);
$('#langES').val(transES);
$('#langFR').val(transFR);
$('#updateDate').val(updateDate);
}
});
Ajax result (example):
array (
'de' => 'Ziffer',
'en' => 'digit',
'da' => 'cifret',
'es' => 'dígito',
'fr' => 'chiffre',
'updateDate' => '2020-05-09 19:40:58',
)
resultthat is received in JS?result- is it a string? Is it wrapped in something?