On 14 Jul., 16:11, Yavuz Bogazci <[EMAIL PROTECTED]> wrote: > is it possible to call php functions from jquery?
My way: PHP: <?php function utf8_encode_recursive(&$arr){ array_walk_recursive($arr,create_function('&$item, $key','$item=utf8_encode($item);')); return $arr; } function utf8_decode_recursive(&$arr){ array_walk_recursive($arr,create_function('&$item, $key','$item=utf8_decode($item);')); return $arr; } if(@$_GET['protocol']!="jsonrpc"){ die("jsonrpc only!"); } if(@$_GET['version']!="1.0"){ die("jsonrpc version mismatch!"); } if(!is_callable('jsonrpc_'[EMAIL PROTECTED]'function'])){ die("uncallable function!"); } if([EMAIL PROTECTED]'parameter']){ $_GET['parameter']=array(); } if(!is_array(@$_GET['parameter'])){ $_GET['parameter']=array($_GET['parameter']); } echo json_encode(utf8_encode_recursive(call_user_func_array('jsonrpc_'.@ $_GET['function'],utf8_decode_recursive($_GET['parameter'])))); ?> JS: $.getJSON( 'helper.php', { protocol:'jsonrpc', version:'1.0', 'function':'myfunc', 'parameter[id]':'4711', 'parameter[value]':'hello world!' }, function(data){ if(window.console){ console.log(data); } } ); > thank a lot > yavuz