Javascript function which pass parameter into a php function. My javascript code is below
function add_card(card_listt,card_number){
var card = card_listt;
var num = card_number;
//document.write(card+num);
for (var i = 0; i < num; i++) {
var avrl = "http://192.168.27.123/?Command=add:"+card[i]+",";
document.write('<?php get_data($avrl); ?>'); // Here is Problem
document.write('<?php add(1,2); ?>'); //It works fine If I use
}
}
my php function is below. when I use only document.write('<?php add(1,2);?>');
function then it works properly. But when I use document.write('<?php get_data($avrl); ?>');
function then it does not works.
<?php
function get_data($url) {
$curl_handle=curl_init();
$timeout = 20;
curl_setopt($curl_handle, CURLOPT_URL,$url);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Welcome');
$data = curl_exec($curl_handle);
//return $data;
echo $data;
}
function add($a,$b){
$c = $a + $b;
echo $c;
}
?>