天道不一定酬所有勤
但是,天道只酬勤

Uncaught TypeError: Cannot call method ‘toLowerCase’ of undefined

出错代码:

 $.ajax({
                 type: "GET",
                 url: 'firstRequest.json?id=' + $(this).val(),
                 async: false,
                 dataType: "json",
                 success: function(data){
                    if(data.deleteable == "true"){
                        $.ajax({
                             type: "GET",
                             url: 'secondRequest.json?id=' + $(this).val(),
                             async: false,
                             dataType: "json",
                             success: function(data){
                                if(data.result=="success"){
                                    alert("删除成功");
                                    reloadPage();
                                }else{
                                    alert("删除失败");
                                }
                             },
                             error: function(XMLHttpRequest, textStatus, errorThrown) {
                                alert("请求失败!");
                             }
                        });
                    }else{
                        alert("无法删除!!!");
                        return false;
                    }
                 },
                 error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert("请求失败!");
                 }
            });

修改之后代码

 var clicked = this;
 $.ajax({
                 type: "GET",
                 url: 'firstRequest.json?id=' + $(clicked).val(),
                 async: false,
                 dataType: "json",
                 success: function(data){
                    if(data.deleteable == "true"){
                        $.ajax({
                             type: "GET",
                             url: 'secondRequest.json?id=' + $(clicked).val(),
                             async: false,
                             dataType: "json",
                             success: function(data){
                                if(data.result=="success"){
                                    alert("删除成功");
                                    reloadPage();
                                }else{
                                    alert("删除失败");
                                }
                             },
                             error: function(XMLHttpRequest, textStatus, errorThrown) {
                                alert("请求失败!");
                             }
                        });
                    }else{
                        alert("无法删除!!!");
                        return false;
                    }
                 },
                 error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert("请求失败!");
                 }
            });
(全文完)
欢迎关注HollisChuang微信公众账号
打赏

如未加特殊说明,此网站文章均为原创,转载必须注明出处。HollisChuang's Blog » Uncaught TypeError: Cannot call method ‘toLowerCase’ of undefined

分享到:更多 ()

HollisChuang's Blog

联系我关于我