A
A
alexrudnikov2019-09-01 13:56:48
PHP
alexrudnikov, 2019-09-01 13:56:48

Return multiple Json ajax values?

JavaScript:

$.ajax({
  url: '../ajax/pay.php',
  type: 'POST',
  cache: false,
  data: {'orderNumber': orderNumber},
  dataType: 'html',
  success: function (data) {
  data = JSON.parse(data);
  if(data[0] > 0) {
  $('#orderPay').text('Подождите...');
  alert(data[1]);
  alert(data[2]);
} else {
  $('#errorBlock').show();
  $('#errorBlock').text(data[1]);
  }
  }
  });
  });

ajax php:
echo json_encode(array(1, $orderId));
  echo json_encode(array(2, $summ));
  echo json_encode(array(3, $title));
  echo json_encode(array(4, $description));

you need to return the order number, amount, date, description, etc.
to write it down in inputs and send it to the payment
. Thank you in advance!!!

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