php file send variable to .js external file
问题 From jquery file to php: $.post('http://botk-online.com/play2.php', { 'rate': Pontuacao.misses }); How to modyficate this code to pass $data variable from php file to js external file and read it value. 回答1: PHP <?php $result = array('data' => 'this is some data'); echo json_encode($result); Javascript: $.ajax({ url: 'http://botk-online.com/play2.php', type: 'post', data: { rate: Pontuacao.misses }, dataType: 'json', success: function(json) { alert('Data is: '+json['data']); // Alerts: 'Data