Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery post数据显示在console.log中,但会触发';未捕获类型错误:对象不是函数';带警报()_Javascript_Php_Jquery_Ajax_Json - Fatal编程技术网

Javascript jQuery post数据显示在console.log中,但会触发';未捕获类型错误:对象不是函数';带警报()

Javascript jQuery post数据显示在console.log中,但会触发';未捕获类型错误:对象不是函数';带警报(),javascript,php,jquery,ajax,json,Javascript,Php,Jquery,Ajax,Json,我被困在这里了。我试图做的是在一篇AJAX文章中向FullCalendar添加一个事件(这可能与此无关)。我返回一个带有PHP json_encode的整数,并尝试检查POST success函数中的值。该值在控制台中正确显示,但当我尝试向它发出警报时,它给出了错误:uncaughttypeerror:object不是函数 这是我的密码: $('[data-form=shtoTakim]').submit(function(e){

我被困在这里了。我试图做的是在一篇AJAX文章中向FullCalendar添加一个事件(这可能与此无关)。我返回一个带有PHP json_encode的整数,并尝试检查POST success函数中的值。该值在控制台中正确显示,但当我尝试向它发出警报时,它给出了错误:uncaughttypeerror:object不是函数

这是我的密码:

                $('[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');
            });

错误具体发生在哪里?我将其注释为“检查部分”,使用jQuery
.css()
函数设置css样式属性,而不是
.attr()
。您能否使用JS代码帮助我们调试。。。(将json字符串添加到js变量…)您可以发布控制台的内容吗?