0

ウォール JS に facebook の投稿を使用しています。投稿の情報は php 経由でエコーされますが、コンソールに次のエラーが表示されます。

SyntaxError: unterminated string literal    

description: 'Well, personal favorite in the following order.<br />

これは API 呼び出しの行です

description: '<?php echo $info['definition'] ?>'

これは SQL データベースの $info['definition'] 文字列です。

Well, personal favorite in the following order.

1. A stalkers dream come true

2. The reason most work are never done on time.

See what I mean with the examples.

他の文字列を使用して直接入力すると、スクリプト エラーが表示されません。文字列をエスケープして API 呼び出しで機能させるにはどうすればよいですか?

4

2 に答える 2

3

次の行を置き換えてみてください。

description: '<?php echo $info['definition'] ?>'

これとともに:

description: "<?php echo preg_replace( '~[\r\n]*~', '', $info['definition'] );?>"
于 2013-05-28T12:18:13.657 に答える
0

文字列からすべての空白を削除する必要があります。Javascript は、すべての新しい行を新しいステートメントと見なします。

于 2013-05-28T12:18:05.357 に答える