javascript - PHP function + Jquery + Ajax -
javascript - PHP function + Jquery + Ajax -
i cant create work. have php script on website (not in php, if wrong, please point me). , want phone call js document.
<?php function doit($option){ if ('getit' == $option){ $value = '318273918739182739179'; homecoming $value; }else{ homecoming 0; } } ?>
and want phone call js file. how pass argument php script via ajax?
var getanswer ={ php: function(){ $.ajax({ url:'mywebsite.com/php/return.php', data: {action, 'doit'}, type: 'post', success: function(output){ alert(output); } }) } }
in javascript:
$.get('yourphpscript.php?argument='+some_arg,function(data){ //data contain result php script });
in yourphpscript:
$option = $_get['argument']; if ('getit' == $option){ $value = '318273918739182739179'; echo $value; }else{ echo "0"; }
php javascript jquery html ajax
Comments
Post a Comment