C
C
CoolBatman2732017-08-27 11:24:14
PHP
CoolBatman273, 2017-08-27 11:24:14

Why var_dump($_POST); returns an empty array?

Here's what the browser returns to me: 24a6e92d5a71424d9812cbcd6ff968c3.png
With this JavaScript code:

$(function() {
  var data = ($("#json").html());
  console.log(data);
  $.ajax({
    type:'POST',
    url: '../index.php',
    data: {data: data},
    success: function(){
      alert('Успех!');
    }
  });
});

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Viktor Yanyshev, 2017-08-27
@villiwalla

And here is console.log(data); what ?

T
ThunderCat, 2017-08-27
@ThunderCat

to start - var data = 10; and check if the value arrives. php code also does not hurt, otherwise guessing on logs without code does not work.
UPD: visually there are no errors in the code, it is difficult to say what specifically violates the script. How do you get, by the way, wardump, ajax then? in the parsing error network console? Try dumping $_REQUEST, nothing else comes to mind, except for non-obvious bugs, server settings and incorrect paths.

M
Maksim Fedorov, 2017-08-27
@Maksclub

var_dump where do you write? I see only js in your code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question