Firefox ReferenceError:...没有定义的问题 [英] Firefox ReferenceError:... is not defined issue

查看:146
本文介绍了Firefox ReferenceError:...没有定义的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Datatables与服务器端处理,我需要添加一些额外的参数,我的查询来做一些过滤。这是我的设置如何:
$ b $ pre $ if($('#example')。length){
var数据表(
bProcessing:true,
bServerSide:true,
sAjaxSource:ajax_url +'?action = load_table_data',
fnServerParams:function(aoData){
aoData.push({name:filters,value:get_table_filters()});
}
}) ;

var tableFilterArray = {};
//设置和更改过滤器等...

函数get_table_filters(){
return JSON.stringify(tableFilterArray);






这个脚本在Chrome中运行正常,但是运行失败在Firefox中,给我以下错误:
$ b $ ReferenceError:get_table_filters没有定义

这里是一个演示: http://jsfiddle.net/HaXUR/3/

我在这里错过了什么?

解决方案

将get_table_filters从if语句中移出

  if($('#example')。length){
var oTable = $('#listings')。dataTable({
bProcessing:true,
bServerSide:true,
sAjaxSource:ajax_url +'?action = load_table_data',
fnServerParams:function(aoData){
aoData.push({name filters,value:get_table_filters()});
}
});
var tableFilterArray = {};


函数get_table_filters(){
return JSON.stringify(tableFilterArray);
}


I'm using Datatables with server side processing, and i need to add some extra parameters to my query to do some filtering. This is how my setup looks like:

if($('#example').length) {
    var oTable = $('#listings').dataTable({
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": ajax_url+'?action=load_table_data',
        "fnServerParams": function ( aoData ) {
             aoData.push( { "name": "filters", "value": get_table_filters() } );
        }
    });

    var tableFilterArray = {};
    //Setting up and changing the filters, etc...

    function get_table_filters() {
        return JSON.stringify(tableFilterArray);
    }
}

The script works fine in Chrome, but fails to run in Firefox, gives me the following error:

ReferenceError: get_table_filters is not defined

Here is a demo: http://jsfiddle.net/HaXUR/3/

What am i missing here?

解决方案

Move the get_table_filters out of the if statement

if($('#example').length) {
var oTable = $('#listings').dataTable({
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": ajax_url+'?action=load_table_data',
    "fnServerParams": function ( aoData ) {
         aoData.push( { "name": "filters", "value": get_table_filters() } );
    }
});
    var tableFilterArray = {};
}

function get_table_filters() {
    return JSON.stringify(tableFilterArray);
}

这篇关于Firefox ReferenceError:...没有定义的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆