Javascript 成功插入未显示的脚本

Javascript 成功插入未显示的脚本,javascript,php,jquery,Javascript,Php,Jquery,我有一个脚本,必须做以下事情。在我插入一些数据后,它必须显示一条带有“inserted Successfully”的消息。它不起作用,但我不知道为什么我对Jquery缺乏经验。我有3个文件 脚本文件: $(document).on("click", ".btnAddSubcat", function(e) { event.preventDefault(); var subcatvalue = $('.subCat').val(); var subcatprocedure = $('.subPro

我有一个脚本,必须做以下事情。在我插入一些数据后,它必须显示一条带有“inserted Successfully”的消息。它不起作用,但我不知道为什么我对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>
            <div class="form-group">
                <label  class="col-sm-2 control-label">Video:</label>
                <div class="col-md-10">
                    <input type="file" name="HWVideo" id="HW-Video" class="form-control uploadVideo" required="true" accept="video/mp4">
                    <video width="450" controls>
                      <source src="mov_bbb.mp4" id="videoLink">
                        Your browser does not support HTML5 video.
                    </video>
                </div>
            </div>
            <div class='form-group'>
                <div class='col-sm-offset-2 col-sm-10'>
                    <input type='hidden' name='Subcatadd' />
                    <button class='btnAddSubcat btn btn-success glyphicon glyphicon-floppy-disk' type='submit'></button>
                </div>
            </div>
            </form>
function AddSubCat() {
$Catid = $_POST['cat-select'];
$Subnaam = $_POST['subCat'];
$procedure = $_POST['Procedure'];
还有一些插入东西。这样就行了,只是它不会显示消息。我感谢你的帮助!一定是这样

插入前的图像 插入后 我找到了这个

$Catid = $_POST['cat-select'];
在AJAX请求中,没有名为cat select的参数。 此外,在使用之前,您应该检查$\u POST和$\u GET是否确实存在。

我发现了这一点

$Catid = $_POST['cat-select'];
在AJAX请求中,没有名为cat select的参数。

此外,在使用之前,您应该检查$\u POST和$\u GET是否确实存在。

您好,这可能是特定于浏览器的。选择chrome。如果是在本地环境中,您应该避免在下面这样的脚本CDN上使用Https://Hi。它可能是特定于浏览器的。选择chrome。如果是在本地环境中,您应该避免在下面这样的脚本CDN上使用Https://浏览器控制台有什么规定?请求是否真的“成功”(意味着HTTP状态代码,进入网络面板)。它只是插入数据,但没有显示成功。为什么要这样做<代码>window.location.reload()尝试注释它或使用setTimeout。使用ajax然后重新加载页面是非常愚蠢的。函数AddSubCat()是干什么的?@fms第三个是我要插入的函数(但我不认为其余的是必要的,因为它插入得很好。浏览器控制台要说什么?请求是否真的“成功”(意味着HTTP状态代码,进入网络面板中的检查)它只是插入数据,但没有成功显示您为什么要这样做?
window.location.reload();
尝试注释它或使用setTimeout。使用ajax然后重新加载页面是非常愚蠢的。AddSubCat()函数是干什么的?@fms第三个是我要插入的函数(但我不认为剩下的部分是必要的,因为它插入得很好,cat select从何而来?从上面的下拉列表中,cat select从何而来?从上面的下拉列表中,我在edge中对其进行了测试,但在chromeCan中不起作用。请共享chrome devTools控制台的屏幕截图。这样我们可以帮助您:)我添加了screenshotsTry这可能会帮助你…我在edge中测试了它,但它在chromeCan中不起作用。请共享chrome devTools控制台的屏幕截图。以便我们可以帮助你:)我添加了screenshotsTry这可能会帮助你。。。