javascript - Not able to access PHP variable -


i struggling/trying since last 24 hours simple thing, not able understand why not able access php variable. know doing wrong , have no idea what's that..

window.alert("variable" + <?php  echo $_post; ?> ); 

its giving me output function array() {[native code]}, how can print values ? , think post attribute blank, can check ? why post variable blank ?

i sending data file via post method

<script type="text/javascript"> function callajaxaddition() {     arguments0 = {         arg1: $("#exampleform input[id='pac-input']").val(),         arg2: ("#exampleform input[id='pac-input']").val()     };     $.ajax({         type: "post",         url: "processajax.php",         data: {             arguments: arguments0         },         success: function(data) {             $("#answer").html('<ul><li>' + data + '</li></ul>');             send_apptn_req();         }     });     return false; } </script> 

and processajax.php file is

<?php $a=0;foreach($_post['arguments'] $v) $a= $v;echo $a;?> 

thanks in advance please..

$_post associative array of variables passed current script.

so need use print_r instead of echo .

window.alert("variable" + <?php  print_r($_post); ?> ); 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -