jQuery通知插件在另一个JS文件中不起作用

jQuery notify plugin not working in another JS file

本文关键字:文件 不起作用 JS 另一个 通知 插件 jQuery      更新时间:2023-09-26

我正在使用jQuery通知插件。我在标题中包含所有 JS 文件。现在我在另一个使用 AJAX 的 JS 文件中调用 $.notify 函数,但在那里我无法访问$.notify函数。

我的 ajax 文件在这里,我也包含在标题中:

$.ajax({
    url:'index.php?page=ajax_insertdimension.php',
    type:'post',
    data:'code='+dcode+'&des='+ddesc,
    success:function(msg){
       $.notify({
        title: 'Email Notification',
        text: 'You received an e-mail from your boss. You should read it right now!',
        image: "<img src='images/Mail.png'/>"
    }, {
        style: 'metro',
        className: 'info',
        autoHide: false,
        clickToHide: true
    });
      addcols();    
    }
   }) 
有时要

使成功方法起作用,您必须指定成功函数参数中的数据类型"msg"参数。这可以通过将dataType参数添加到 post 方法来完成,如此处的文档 jQuery.post() 中指定

$.ajax({
url:'index.php?page=ajax_insertdimension.php',
type:'post',
data:'code='+dcode+'&des='+ddesc,
success:function(msg){
   $.notify({
    title: 'Email Notification',
    text: 'You received an e-mail from your boss. You should read it right now!',
    image: "<img src='images/Mail.png'/>"
}, {
    style: 'metro',
    className: 'info',
    autoHide: false,
    clickToHide: true
});
  addcols();    
},dataType: "json"})

这应该为您完成工作。您可以将调试器放入成功函数并进行测试,无论您的回调是否被调用。