0

我有以下代码:

FB.getLoginStatus(function (response) {
    if (response.status === "connected") {
        FB.api("me/bookvote:download", "post", {

        }, //Missing a , here?

但是,我仍然得到:

 Uncaught SyntaxError: Unexpected identifier 
 for  book: "<?php echo "http://mysite.xom/auction_details.php?name=$item_details["name"]&auction_id=$item_details["auction_id"]";?>",

我的 php 变量到 JavaScript 可能有什么问题?

4

3 回答 3

3

将 { } 包裹在字符串中的数组项周围,例如{$item_details["name"]}

于 2013-03-21T22:37:06.013 回答
1

不再支持魔术引号。改变

book: "<?php echo "http://mysite.xom/auction_details.php?name=$item_details["name"]&auction_id=$item_details["auction_id"]";?>",

book: "<?php echo "http://mysite.xom/auction_details.php?name=" . $item_details["name"] . "&auction_id=" . $item_details["auction_id"];?>",

于 2013-03-21T22:37:32.653 回答
1

您没有在 PHP 代码中正确连接:

FB.getLoginStatus(function (response) {
    if (response.status === "connected") {
        FB.api("me/bookvote:download", "post", {
            book: "<?php echo 'http://mysite.xom/auction_details.php?name='. $item_details['name'] . '&auction_id=' . $item_details['auction_id']; ?>",
            fb:explicitly_shared = "true" //? Is syntactically valid but creates a global
        },

为了便于阅读,我将 PHP 代码中的双引号替换为单引号。

于 2013-03-21T22:38:23.780 回答