A
A
Alexander Sobolev2018-07-01 23:46:51
PHP
Alexander Sobolev, 2018-07-01 23:46:51

Php doesn't see $_POST['data'] passed by ajax?

I can’t understand why the post-array is lost during the transfer.. help me figure it out

var data = {
                action: "edit_servise",
                servise_id : servise_id,
                current_servise_key : current_servise_key,
                current_servise_label : current_servise_label,
                current_servise_cost : current_servise_cost,
                upd_servise_label : upd_servise_label,
                upd_servise_cost : upd_servise_cost

              };	
          jQuery.post( ajaxurl, data, function(response) {
            console.log('Получено с сервера: ' + response);
          });

if(isset($_POST['data']) )	{
    $data = $_POST['data'];
    echo $data['servise_id'];
  } 
  else {echo 'не пришло';}

The console writes did not come (

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2018-07-02
@san_jorich

So you don't pass $_POST['data']. Do a var_dump($_POST) and see what comes up.

K
KTF, 2018-07-02
@KTF

Because you are transmitting

$_POST['action'], $_POST['servise_id'], $_POST['current_servise_key']
etc.
PS The word service in English is written like this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question