JQuery 周日历问题
在我的项目中,我使用 JQuery 周日历插件。我调用 php 脚本来检索数据并将其显示在日历中。以下是我的
var id = 3;
var type = "c";
var dataString = "id=" + id + "&t=" + type;
$.ajax({
type:"post",
url:"actions/client.php",
data: dataString,
dataType:"json",
success: function(data){
alert(data);
}
});
PHP 代码:
function getCalendarData($appoint_id){
$retunArray = array();
$sql = "SELECT id, appoint_start, appoint_end, total FROM account WHERE id = '".$appoint_id."'";
$result = mysql_query($sql);
while($row = mysql_fetch_object($result)){
$retunArray[] == $row;
}
echo json_encode($retunArray);
}
它给了我 500 错误。以前有人用过 PHP 吗?有人可以帮我从数据库获取数据并显示吗?还有比这更好的替代方法吗
谢谢
In my project, I am using the JQuery week calendar plugin. I call a php script to retrieve the data and show it in the calandar. Following is my code
var id = 3;
var type = "c";
var dataString = "id=" + id + "&t=" + type;
$.ajax({
type:"post",
url:"actions/client.php",
data: dataString,
dataType:"json",
success: function(data){
alert(data);
}
});
In PHP:
function getCalendarData($appoint_id){
$retunArray = array();
$sql = "SELECT id, appoint_start, appoint_end, total FROM account WHERE id = '".$appoint_id."'";
$result = mysql_query($sql);
while($row = mysql_fetch_object($result)){
$retunArray[] == $row;
}
echo json_encode($retunArray);
}
It gives me a 500 error. Has anyone used it before with PHP. Can anybody help me to get the data from the db and show? any alternative good way than this
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查浏览器中的响应。如果您使用 G.Chrome,请按 F12,单击“网络”选项卡,然后单击底部的“XHR”。单击响应以展开信息
也许您正在压缩 JSON 数据,
你使用任何php框架吗?
Check the response in your browser. If you use G. Chrome press F12, click in Network tab and in the bottom click on XHR. Click in the response to expand the information
Maybe you are gzipping the JSON data,
are you using any php framework?