mardi 4 août 2015

Send numbers from php to js in separated files

How to send variables from php to js in separated files. Can I make this without ajax or I need ajax for this. If I need ajax how to make with ajax.

test.php

<?php
$a = 5;
$b = 10;
?>

test.js

var sum =<?php echo $a?> + <?php echo $b?>
document.write(sum);

Aucun commentaire:

Enregistrer un commentaire