[英]Uncaught TypeError: $(…).ajaxForm is not a function
I am trying to submit the form using ajaxForm and redirect to the view.我正在尝试使用 ajaxForm 提交表单并重定向到视图。 But, I am getting uncaught type error (...).ajaxForm is not a function.
但是,我收到未捕获的类型错误(...)。ajaxForm 不是 function。
My code:我的代码:
$(document).ready(function () {
loadMainInputs();
loadSubCategory(<?php echo $model->category_id; ?>);
$("#Posts-form").ajaxForm({
beforeSend: function () {
return $("#Posts-form").validate({
rules: {
name: {
required: true,
}
},
messages: {
name: {
max: "Customize Your Error"
}
}
}).form();
},
beforeSubmit: function () {
$("#btn-save").html("Loading....");
$("#btn-delete").attr("disabled", true);
$("#btn-submit").attr("disabled", true);
},
success: function (data) {
var result = JSON.parse(data);
if (result.id != 0) {
window.location.href = "<?php echo Yii::app()->createUrl("posts"); ?>/";
}
showResponse(data);
}
});
});
The ajaxForm function appears to not be native from jQuery and instead comes from a jQuery plugin, jQuery Form Plugin . ajaxForm function 似乎不是来自 jQuery 的本机,而是来自 jQuery 插件ZF590B432C30BE28DDC Form Including this plugin in your code should solve your problem.
在你的代码中包含这个插件应该可以解决你的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.