[英]Calling to function code error in else statment
when I use the code like this I got error that in compile time that expression statement is not assigment or call... (inside the else statment) 当我使用这样的代码时,我得到一个错误,在编译时该表达式语句没有被赋值或调用...(在else语句中)
What I miss here to make it work ?i've tried to play with the bracktes without success:( I new to JS/Jquery ... 我想让它工作的是我想念的吗?我试图与小家伙玩耍而没有成功:(我是JS / Jquery的新手...
The error is inside the else statment... 错误在else陈述中...
error: errorCreation, dataType: "json";
错误:errorCreation,数据类型:“ json”;
function create() {
......
$.ajax({
type: "POST",
url: '@Url.Action("Create", "Users")',
data: postData,
success: function(result) {
if (data.ErrorMsg == null) {
// success
} else {
// error msg
error: errorCreation,
dataType: "json";
}
}
});
return false;
};
The correct syntax would look something like this: 正确的语法如下所示:
$.ajax({
type: "POST",
url: '@Url.Action("Create", "Users")',
data: postData,
success: function (result) {
if (data.ErrorMsg != null) {
// success stuff
} else {
errorCreation(); // do you want this function to run here?
// error message stuff
}
},
error: errorCreation, // or here?
dataType: "json"
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.