dpy3846
2011-09-07 00:45
浏览 93

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!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dpvmtdu364462 2011-09-07 00:53
    已采纳

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

    点赞 评论
  • dsh102123 2011-09-07 00:55

    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.

    点赞 评论

相关推荐 更多相似问题