E
E
Egor Razinsky2020-04-26 12:35:47
PHP
Egor Razinsky, 2020-04-26 12:35:47

Problem with json getting data from php?

Hello, can someone explain one thing to me. why when passing data via ajax with php when i create json string in this way

echo json_encode($s = array(array('grief' => $buys1,'skyblock' => $buys2),array('grief' => $buys1+1,'skyblock' => $buys2+1)));
Everything works fine, but I need to make this list separately
$s = array(array('grief' => $buys1,'skyblock' => $buys2),array('grief' => $buys1+1,'skyblock' => $buys2+1));
    echo json_encode($s);
as a function
function fsuccess(datadel){
  var dat = JSON.parse(datadel);
starts throwing the error "SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data"
What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2020-04-26
@galaxy

F12 and see what comes over the network and how it differs in two cases

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question