我有一个脚本,必须执行以下操作。在插入一些数据之后,它必须显示一条消息“成功插入”。它不起作用,但是我不知道为什么我对Jquery缺乏经验。我有3个档案。
脚本文件:
$(document).on("click", ".btnAddSubcat", function(e) {
event.preventDefault();
var subcatvalue = $('.subCat').val();
var subcatprocedure = $('.subProcedure').val();
var url = "../service/functions/postActions.php";
swal({
title: 'Add a new sub-category?',
text: "Are you sure to Add this sub-category?",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, Add it!'
}).then(function () {
$.ajax({
type: 'POST',
url : url,
data: {'subCat': subcatvalue, 'Procedure': subcatprocedure},
success: function (data) {
swal({
title: 'Add!',
text: "You Add a sub-category!",
type: 'success',
confirmButtonColor: '#3085d6',
confirmButtonText: 'OK'
}).then(function () {
window.location.reload();
})
}
});
})
});
PHP文件
<div class="form-group">
<label for="inputsubcat" class="col-sm-2 control-label">SubCategory:</label>
<div class="col-sm-10">
<input type="text" class="form-control subCat" name="subCat" placeholder="...">
</div>
</div>
<div class="form-group">
<label for="inputprocedure" class="col-sm-2 control-label">Procedure:</label>
<div class="col-sm-10">
<textarea name="Procedure" rows="8" cols="30" style=" resize: none;" class="form-control subProcedure" placeholder="..."></textarea>
</div>
</div>
功能文件
function AddSubCat() {
$Catid = $_POST['cat-select'];
$Subnaam = $_POST['subCat'];
$procedure = $_POST['Procedure'];
和一些插入的东西。可以,但不会显示该消息。我感谢您的帮助!一定是这样
插入
后插入 之前的图像
鸿蒙传说
桃花长相依
相关分类