0

我被困在这里。我想要做的是做一个 AJAX 帖子来向 FullCalendar 添加一个事件(这可能是无关紧要的)。我正在使用 PHP json_encode 返回一个整数并尝试检查 POST 成功函数中的值。该值在控制台中正确显示,但是当我尝试警告它时,它给出了错误:Uncaught TypeError: object is not a function

这是我的代码:

                $('[data-form=shtoTakim]').submit(function(e){
                e.preventDefault();

                $.fn.spin.presets.ss = {
                    lines: 9, // The number of lines to draw
                    length: 5, // The length of each line
                    width: 2, // The line thickness
                    radius: 3, // The radius of the inner circle
                    corners: 1, // Corner roundness (0..1)
                    rotate: 0, // The rotation offset
                    direction: 1, // 1: clockwise, -1: counterclockwise
                    color: '#fff', // #rgb or #rrggbb or array of colors
                    speed: 1.3, // Rounds per second
                    trail: 53, // Afterglow percentage
                    shadow: false, // Whether to render a shadow
                    hwaccel: false, // Whether to use hardware acceleration
                    className: 'spinner', // The CSS class to assign to the spinner
                    zIndex: 2e9, // The z-index (defaults to 2000000000)
                    top: 'auto', // Top position relative to parent in px
                    left: '34px' // Left position relative to parent in px
                };

                var but = $(this).find('button');

                but.text('').prop('disabled', true).attr('style', 'height: 30px;');
                $('[data-type=spinner]').spin('ss');

                var url = $(this).attr('action');
                var data = $(this).serialize() + '&date=' + $('[data-type=date]').html();

                // var title = "Title";
                $.post(url, data, function(data){
                    $('[data-type=spinner]').spin(false);
                    but.text('Aggiungi').prop('disabled', false).removeAttr('style');

                    // the checking part
                    console.log(data);
                    alert(data);
                    if(data == 4)
                    {
                        alert('Hello World');
                    }

                    $('#calendar').fullCalendar('refetchEvents');
                    ev = new Object();
                }, 'json');
            });
4

0 回答 0