当echo $ _GET [“" jsoncallback“]时发生错误 [英] Error when echo $_GET["jsoncallback"]
本文介绍了当echo $ _GET [“" jsoncallback“]时发生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<?php
$query = mysql_query("Select id, name From table");
while($row = mysql_fetch_array($query)) {
echo $_GET["jsoncallback"] . '(<option value='.$row['id'].'>'.$row['name'].'</option>)';
}
?>
当我回显结果时,这是错误,如何解决?
When I echo result, it is error, how to fix it?
推荐答案
由于您未完全编写要执行的操作,因此我猜测您正在尝试返回JS的HTML选项列表回调函数将放置在您的文档中.
Since you didn't write exactly what you're trying to do, i'm guessing you're trying to return a list of HTML options that a JS callback function will place in your document.
尝试一下:
<?php
$options = '';
$query = mysql_query("Select id, name From table");
while ($row = mysql_fetch_array($query)) {
$options .= '<option value="'.$row['id'].'">'.$row['name'].'</option>' . "\n";
}
echo $_GET["jsoncallback"] . "('" . $options . "');";
?>
这将首先将所有选项创建为字符串,然后再构建回调.
This will first create all the options as a string, and only then build the callback.
这篇关于当echo $ _GET [“" jsoncallback“]时发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文