I'm very new to this and I've searched around all day today to get it working but I haven't managed to find a way to use a variable, only hard-coded values work. Here is my code with a hard-coded value:
<script type="text/javascript">
FB.Event.subscribe('edge.create',
function(response) {
$.post("http://www.my-domain.com/fbtest.php", { category: "845" } );
}
);
</script>
What I'd like to have is change that 845 value to a variable called $vpostid. When I change it to that it doesn't work, so I assume I need to get the double quotation marks around the number but I can't see to get the correct combination.
I'm assuming you mean "pass variable from php":
If short hand openings are enabled:
<script type="text/javascript">
FB.Event.subscribe('edge.create',
function(response) {
$.post("http://www.my-domain.com/fbtest.php", { category: "<?=$vpostid?>" } );
}
);
</script>
else:
<script type="text/javascript">
FB.Event.subscribe('edge.create',
function(response) {
$.post("http://www.my-domain.com/fbtest.php", { category: "<?php echo $vpostid; ?>" } );
}
);
</script>
try this code:
<script type="text/javascript">
FB.Event.subscribe('edge.create',
function(response) {
$.post("http://www.my-domain.com/fbtest.php", { category: "<?php echo($vpostid); ?>" } );
}
);
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.