我在核心2.1 mvc项目中有一个简单的ajax调用,当ajax被称为获取错误时。
Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
at jQuery.fn.init.val (jquery-3.3.1.js:7977)
at Object.success (site.js?v=OUF1Fik5ylnQznBsXzwsHKsbqx7WPO22Vc7NQmDmM-c:268)
at fire (jquery-3.3.1.js:3268)
at Object.fireWith [as resolveWith] (jquery-3.3.1.js:3398)
at done (jquery-3.3.1.js:9305)
at XMLHttpRequest.<anonymous> (jquery-3.3.1.js:9548)
at Object.send (jquery-3.3.1.js:9600)
at Function.ajax (jquery-3.3.1.js:9206)
at HTMLButtonElement.<anonymous> (site.js?v=OUF1Fik5ylnQznBsXzwsHKsbqx7WPO22Vc7NQmDmM-c:249)
at HTMLDocument.dispatch (jquery-3.3.1.js:5183)
val @ jquery-3.3.1.js:7977
success @ site.js?v=OUF1Fik5ylnQznBsXzwsHKsbqx7WPO22Vc7NQmDmM-c:268
fire @ jquery-3.3.1.js:3268
fireWith @ jquery-3.3.1.js:3398
done @ jquery-3.3.1.js:9305
(anonymous) @ jquery-3.3.1.js:9548
send @ jquery-3.3.1.js:9600
ajax @ jquery-3.3.1.js:9206
(anonymous) @ site.js?v=OUF1Fik5ylnQznBsXzwsHKsbqx7WPO22Vc7NQmDmM-c:249
dispatch @ jquery-3.3.1.js:5183
elemData.handle @ jquery-3.3.1.js:4991
load (async)
send @ jquery-3.3.1.js:9567
ajax @ jquery-3.3.1.js:9206
(anonymous) @ site.js?v=OUF1Fik5ylnQznBsXzwsHKsbqx7WPO22Vc7NQmDmM-c:249
dispatch @ jquery-3.3.1.js:5183
elemData.handle @ jquery-3.3.1.js:4991
我只是通过传递一个变量来调用ajax来调用控制器,而html会刷新模式html
$.ajax({
url: "/Home/CreateAddModalModel",
type: "POST",
async: false,
data: {
languageSelected: languageSelected
},
beforeSend: function () {
},
success: function (data) {
$("#AddModalBody").html("");
$("#AddModalBody").html(data);
// Sync main dropdown with the one on the edit modal. Fire change event to reload transliterated rows
$("#AddModalLanguagesDDLList")
.val($(this).val())
.trigger('change');
},
error: function (xhr, status, error) {
}
});
});