S
S
Sevelin2019-06-14 09:08:06
PHP
Sevelin, 2019-06-14 09:08:06

Why is the data not being sent in json format?

Good afternoon. Unfortunately, I don’t fully understand the php + js bundle, and, accordingly, it’s hard to navigate with ajax. When I pass data from the form and process it, the data is transferred well, but if I send data using then I get an error
if(!empty($_POST)){ }
if(isset($_POST['name'])){ }

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data


How can I check what data my ajax script receives?
It just turns out that the second option is more representative for me, since I need to send several forms from one page.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hack504, 2019-06-14
@hack504

In Google Chrome Ctrl+Shift+I Network tab - here you will see what data the php script sends

K
Kirill Gorelov, 2019-06-14
@Kirill-Gorelov

I had the same problem the other day.
And I'm willing to bet it's the quotation marks.
This build helped me.
addslashes(json_encode($video,JSON_HEX_QUOT));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question