Javascript Datatables:如何从另一个函数获取变量值

Javascript Datatables:如何从另一个函数获取变量值,javascript,datatables,Javascript,Datatables,我面临着一个小问题。如何从Datatables中的另一个函数获取变量值 我的Javascript代码: var id = ""; var type = ""; show = function(id, type){ //id=5, type=3 id = id; type = type; } var pTable = $("#example").DataTable({ processing: true, serverSide: true,

我面临着一个小问题。如何从Datatables中的另一个函数获取变量值

我的Javascript代码:

var id = "";
var type = "";

show = function(id, type){ //id=5, type=3
        id = id;
        type = type;
}

var pTable = $("#example").DataTable({
    processing: true,
    serverSide: true,
    sort: true,
    ajax: {
        url: "/url/"+id+"/"+type,
        dataType:"json"
    },
控制台日志结果:

GET: /url///;
如何获得价值?
抱歉英语不好。

更改显示功能如下:

show = function(_id, _type){ 
    id = _id;
    type = _type;}

更改显示功能如下:

show = function(_id, _type){ 
    id = _id;
    type = _type;}

我通过以下代码解决了我的问题:


pTable.ajax.url(“/url/”+id+“/”+type).load()

我通过以下代码解决了我的问题:


pTable.ajax.url(“/url/”+id+“/”+type).load()

是的,使用与相同名称的参数不是一个好主意variables@chris97ong+1这是一样的。是的,用与相同名称的参数不是一个好主意variables@chris97ong是一样的。