Javascript变量给出了未定义的错误? [英] Javascript variable gives undefined error?
本文介绍了Javascript变量给出了未定义的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码:
I have following code:
var employee = '';
function FillEmployee()
{
$.ajax({
type: "POST",
url: 'http://localhost:1732/GridViewExample/ClientServerInterface.aspx/GetEmployee',
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
success: function (id)
{
employee = id.d.employee;
PopulateValueDropDown(employee);
}
});
}
以上代码变量员工中的
给出了未定义的错误,但我已经全局定义。
in above code variable employee gives undefined error but i have already globaaly defined.
推荐答案
.ajax({
type: POST,
url:' http:// localhost:1732 / GridViewExample / ClientServerInterface.aspx / GetEmployee',
数据: {},
contentType: application / json; charset = utf-8,
dataType: json,
async: false ,
成功: function (id)
{
雇用ee = id.d.employee;
PopulateValueDropDown(员工);
}
});
}
.ajax({ type: "POST", url: 'http://localhost:1732/GridViewExample/ClientServerInterface.aspx/GetEmployee', data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", async: false, success: function (id) { employee = id.d.employee; PopulateValueDropDown(employee); } }); }
上面代码变量员工中的
给出了未定义的错误,但我已经全局定义。
in above code variable employee gives undefined error but i have already globaaly defined.
更改变量名称
var employee = '''';
到其他名称
var emp = '''';
并在代码中使用该变量。
and use that variable in the code.
这篇关于Javascript变量给出了未定义的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文