receive a request from ajax and execute an action

<?php if(isset($_REQUEST['action'])) { //testa se algum método tasetado na url $action = $_REQUEST['action']; $var = isset($_REQUEST['randn']) ? $_REQUEST['randn'] : null; echo $action($var); // retorna o valor da função que foi chamada pelo ajax. } function mydata($randn){ $array = array(//aqui tu retorna o teu array ou hashmap para o servidor...passando pelo jsonencode e no js tufaz o parse dele para transforma-lo em obj. 1 => "data ajax ". $randn, 2 => "data ajax 2".($randn+1), ); return json_encode($array); } ?>

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.