首页 新闻 会员 周边

在$.ajax()中,给变量赋值不起作用

0
悬赏园豆:10 [已关闭问题] 关闭于 2012-01-19 00:30
 1 //新建文件夹弹出框
2 Core.PUB.show_new_box = function (e) {
3 var html = "<div style='padding:24px 45px;background-color: white;'><input type='text' id='filename' name='filename' class='text' /></div>";
4 var submit = function (v, h, f) {
5 if (v == 0) {
6 return true;
7 }
8 else {
9 if (f.filename == '') {
10 $.jBox.tip("请输入文件夹名称。", 'error', { focusId: "filename" }); // 关闭设置 yourname 为焦点
11 return false;
12 }
13 else {
14 var b = true;
15 $.ajax({
16 type: "GET",
17 dataType: "json",
18 data: "ParentId=" + e + "&Title=" + f.filename + "&time=" + (new Date().getTime()),
19 url: Core.CONFIG.SiteUrl + "/class/DocOls.Web/WenJianJia.aspx?act=Create",
20 error: function (XmlHttpRequest, textStatus, errorThrown) { if (XmlHttpRequest.responseText != "") { $.jBox.tip(XmlHttpRequest.responseText); } },
21 success: function (data) {
22 if (data.result == '0') {
23 $.jBox.tip(data.error, 'error', { focusId: "filename" });
24 b = false;
25 }
26 else {
27 $.jBox.tip("您新建了“" + f.filename + "”文件夹!");
28 window.setTimeout(function () { window.location = Core.CONFIG.SiteUrl + "/User/doclist.aspx"; }, 1000);
29 }
30 }
31 });
32 return b;
33 }
34 }
35 };
36
37 $.jBox(html, { title: "新建文件夹", width: 420, height: 143, top: '30%', buttons: { '确定': 1, '取消': 0 }, submit: submit });
38 }

在第14行我定义了一个变量b=true,然后通过ajax提交给后台,在24行中,根据返回的参数,给b赋值b=false,但是,到了第32中,这个B依然是个true。....

就是说,在$.ajax()中,我这个b的赋值不起作用了。

豆腐欣欣的主页 豆腐欣欣 | 初学一级 | 园豆:76
提问于:2012-01-18 23:49
< >
分享
所有回答(1)
0

我看是执行了你的else语句吧。

Zjmainstay | 园豆:355 (菜鸟二级) | 2012-08-28 13:54
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册