A
A
alexander_chn2018-02-11 22:29:00
PHP
alexander_chn, 2018-02-11 22:29:00

How to convert $_POST to php array?

Hello! The task is this:
There are 5 checkboxes:

<input value="12 м" name="meters[]" id="12m" class="check" type="checkbox"><label for="12m">12м</label>

They differ only in the value parameter.
The form is sent with the post method and the script needs to bring them to an array of the form: Here is another send code:
array("12 м", "13 м", "14 м"); и т.д.
function send_calc() {
  //0 = unsuccessful email sending
  //1 = sent successfully
  var msg = $('#form_calc').serialize();
  $.ajax({
    type: 'POST',
    url: '/script.php',
    // dataType: 'json',
    data: msg,
    success: function(data) {
        $("#calc_res").html(data);
        $("#calc_res").css("display", "block");
        $('#form_calc')[0].reset();
    },
    error: function(xhr, str) {
      alert('Error: ' + xhr.responseCode + ' Please, try again later.');
    }
  });
}

How to make this transformation?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question