如果(data.success)在下面的调用中收到此错误,则数据为空

时间:2012-07-16 08:38:11

标签: jquery ajax null

 <script type="text/javascript">
    function submitcustomerservice()

    {
        var formArray = $('#addcustomerservicesform').serialize();
        $.post('<?php echo base_url();?>index.php/home/save_customer_service', formArray, function (data) {
            if (data.success) {
                var customerid = $('#customerid').val();
                window.location.replace('<?php echo base_url();?>index.php/home/customer_profile/' + customerid);
            } else

            {
                for (var i in data.errors)

                {
                    $('#' + i).validationEngine('showPrompt', data.errors[i], '', 'topRight', true);
                }

                for (var z in data.hidden)

                {
                    $('#addcustomerservicesform #' + data.hidden[z]).validationEngine('hide');
                }

            }

        }, 'json');

        return false;

    }

当我点击我的保存按钮时触发上面的代码,它应该检查并保存表单中的所有数据,添加data['success']时设置为true,如果有任何错误{{1} }设置为各自的错误。我有它在localhost上工作,但当我上传到我的主网站时,它给我的数据错误是data['errors']。请让我知道你对它的看法。这可能是一个什么问题?

1 个答案:

答案 0 :(得分:0)

它请求的页面可能并不像您认为的那样正常工作。

安装firebug,并观看网络标签。然后看看实际页面返回的内容。

BTW您确定base_url()功能吗?你可能不需要它 - 你可以做一个相对网址。