jQuery $ .ajax不起作用

I wrote a code using jQuery plugin fullcalendar, and everything worked just fine, until I send an $.ajax request in the eventClick.

I tried to alert something in the eventClick and it worked, but the ajax request just doesn't work. js code:

            !function($)
        {

            $(document).ready(function() {

                $("#eventDialog").dialog({
                    autoOpen : false,
                    modal : true
                });

                var date = new Date();
                var d = date.getDay();
                var m = date.getMonth();
                var y = date.getFullYear();

                $("#calendar").fullCalendar({

                    theme : true,

                    header : {
                        left : 'next,prev today',
                        center : 'title',
                        right : 'month,agendaWeek,agendaDay'
                    },

                    editable : false,

                    events : [
                        <?php
                            while ($event = mysql_fetch_array($selectevents))
                            {
                                $startd = explode(".", $event['start']);
                                $endd = explode(".", $event['end']);

                                $starth = explode(":", $event['starth']);
                                $endh = explode(":", $event['endh']);
                        ?>
                        {

                            id : <?php echo $event['id']; ?>,
                            title : '<?php echo stripslashes($event['title']); ?>',
                            <?php
                                if ($event['allday'] == 1)
                                {
                            ?>
                            start : new Date(<?php echo $startd[2]; ?>,<?php echo $startd[1]-1; ?>,<?php echo $startd[0]; ?>),
                            end : new Date(<?php echo $endd[2]; ?>,<?php echo $endd[1]-1; ?>,<?php echo $endd[0]; ?>)
                            <?php
                                }
                                else
                                {
                            ?>
                            start : new Date(<?php echo $startd[2]; ?>,<?php echo $startd[1]-1; ?>,<?php echo $startd[0]; ?>,<?php echo $starth[0]; ?>,<?php echo $starth[1]; ?>),
                            end : new Date(<?php echo $endd[2]; ?>,<?php echo $endd[1]-1; ?>,<?php echo $endd[0]; ?>,<?php echo $endh[0]; ?>,<?php echo $endh[1]; ?>),
                            allDay : false
                            <?php
                                }
                            ?>
                        }
                        <?php
                                $evNum--;
                                if ($evNum > 0)
                                    echo ",";
                            }
                        ?>
                    ],

                    eventClick : function(event) {

                        var eid = event.id;

                        $.ajax({
                            type : "GET",
                            url : "getEvent.php",
                            data : "id=" + eid,
                            succuss : function(msg) {

                                var title = $("event title", msg).text();
                                var description = $("event description", msg).text();
                                var start = $("event start", msg).text();
                                var end = $("event end", msg).text();
                                var starth = $("event starth", msg).text();
                                var endh = $("event endh", msg).text();

                                $("#eventDialog").attr("title", title);
                                $("#eventDialog #edDescription").html(title);

                                eventDialog.dialog("open");

                            }
                        });

                    }

                });

            });

        }(jQuery);

getEvent.php

    $id = htmlspecialchars(mysql_real_escape_string($_GET['id']));

$selectevent = mysql_query("SELECT * FROM `calendar` WHERE `id`='$id'") or die(mysql_error());
$event = mysql_fetch_array($selectevent);

header("Content-Type: text/xml; charset=utf-8");
echo '<?xml version="1.0" encoding="utf-8" ?>';

echo "<event>";
echo "<id>".$event['id']."</id>";
echo "<title>".stripslashes($event['title'])."</title>";
echo "<description>".$event['description']."</description>";
echo "<start>".$event['start']."</start>";
echo "<end>".$event['end']."</end>";
echo "<starth>".$event['starth']."</starth>";
echo "<endh>".$event['endh']."</endh>";
echo "</event>";

Can anybody point out the problem?

Thank's!

dpmopn8542
dpmopn8542 Laberge:他让服务器端在发送到客户端并执行之前编写javascript。所以是的,这将起作用..虽然,它不是最好的做法。
大约 9 年之前 回复
dongniuxia8650
dongniuxia8650 定义“不起作用”。当你调试它时,它在哪里偏离预期的执行路径?请求是否被发送到服务器?它是否收到服务器的响应?“不起作用”可能意味着什么。
大约 9 年之前 回复
dongyingjiu0669
dongyingjiu0669 你有PHP代码在JavaScript中?PHP是服务器端语言,javascript是客户端。
大约 9 年之前 回复

2个回答



succuss ??,我猜这是你的问题,应该是“成功”</ p>
</ div>

展开原文

原文

succuss??, i guess is this your problem , it should be "success"

douhong6187
douhong6187 好的,这是我之前错误删除的一行。
大约 9 年之前 回复
douhan8581
douhan8581 好的捕获,我从未见过
大约 9 年之前 回复



在代码中将 succuss </ code>更改为 success </ code>,它必须是拼写错误。 </ p>

由于 jQuery </ code> $。ajax </ code>在其设置中未找到 success </ code>处理程序,因此它没有 做任何事情。</ p>
</ div>

展开原文

原文

Change succuss to success in your code it must be a typo.

Since jQuery $.ajax did not find the success handler in its settings it didn't do anything.

duanna1407
duanna1407 你能确定正在打电话吗?
大约 9 年之前 回复
douyu7879
douyu7879 好的,这是我之前删除的一行。 需要更改为$(“#eventDialog”)。dialog(“open”);
大约 9 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问