php değişken içine json değer çözdüğü

1 Cevap php

Ben sadece aşağıdaki gibi getJSON gelen parseInfo sonuçları () işlevi geçirdiğinizde, ben başka bir php fonksiyonu sayesinde son koyabilirsiniz böylece geri php değişken içine sonuç almak mümkün değildir.

$.getJSON('getinfo.php', { id:id }, parseInfo);

function parseInfo(data) {
   <?php 
      $some_var = json_decode(data);
      function some_function($some_var) {
         // rest of the script here...
      } 
   ?>
}

Can anyone please help me out with this? I would really appreciate it.
Cheers!

1 Cevap

Sayfa gönderilir ÖNCE PHP çalışır. Javascript sayfa gönderilir SONRA çalışır. Bu nedenle PHP çalıştırabilirsiniz için tek yolu bir sayfa talep etmektir.

PHP ile veri aktarmak istedim Yani, sizin gibi başka bir sayfa aramak olurdu ajax.php:

<?php

$data = $_POST['data'];
// ... do stuff ...

?>

Lütfen komut:

$.post('ajax.php', data);

Bu bak question.