小编Tyl*_*vis的帖子

将朋友姓名的php字符串传递给javascript函数

我正在尝试将php字符串传递给javascript函数.php部分看起来像这样:

<?php
   foreach ($friends as $key => $friend) {
   // Extract the pieces of info we need from the requests above
   $id = assertNumeric(idx($friend, 'id'));
   $name = idx($friend, 'name');
   // Here we link each friend we display to their profile
   echo('
     <li>
     <a href="#" onclick="window.open(\'http://www.facebook.com/' . $id . '\')">
     <img src="https://graph.facebook.com/' . $id . '/picture?type=square" alt="' . $name . '">'. $name . '
    </a>
    <form>
    <input type="button" value="Meet" onclick="postMeet(. $name.)"/>
    </form>
    </li>');
    }
?>
Run Code Online (Sandbox Code Playgroud)

javascript函数看起来像这样.如果我将$ key或$ id传递给函数但没有传递$ name,它的工作正常.有人有任何想法吗?我是php和javascript的新手.

<script type="text/javascript"> …
Run Code Online (Sandbox Code Playgroud)

javascript php facebook-graph-api posts

1
推荐指数
1
解决办法
2521
查看次数

标签 统计

facebook-graph-api ×1

javascript ×1

php ×1

posts ×1