I have an Ajax function to load all columns names and their values via php as follow:
PHP SIDE:
$res = $db->query($stmt);
$rsltz= array();
while ($row = $res->fetchArray(SQLITE3_ASSOC)) {
foreach ($row as $colonne => $valeur) {
$rsltz[$colonne] = isset($valeur) ? $valeur : "";
}
}
header('Content-type: application/json');
echo (json_encode($rsltz));
AJAX FUNCTION:
function jet(a,b,c){
$.ajax({
type: 'POST',
cache: false,
url: 'builder.php',
data: { typ:a, lg:b ,menu:c},
success: function(result) {
if(typeof(result) === "string") {
$('#par').after(result);
} else {
//JSON hier comes a loop to display key=>val
var pars = JSON.parse(result);
$('#par').after(pars.datasrc);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert(jqXHR+'
'+textStatus+'
'+ errorThrown);
}
});
}
I have this error:
here the json.encoded result :
{"id":"510","menu":"regis","taketo":"regis1","auth":"ALL"}
I do appreciate any help ?.
question from:
https://stackoverflow.com/questions/65937587/why-am-i-getting-this-invalid-parse 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…