ajax请求中的msg插件

时间:2013-03-05 18:30:03

标签: jquery

我目前正在考虑这个plugin,因为blockui似乎不适合我。我正在使用:

beforeSend: function () {
    $.msg({
    autoUnblock: false
    });
}

并希望“取消阻止”它成功,错误等。

这可能吗?感谢。

1 个答案:

答案 0 :(得分:1)

是的,这是可能的。

我刚刚测试过,它可以尝试这样:

<强> HTML

<!DOCTYPE html>
<html>
<head>
  <link media="screen" href="https://raw.github.com/dreamerslab/jquery.msg/master/jquery.msg.css" rel="stylesheet" type="text/css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
  <script src="https://raw.github.com/dreamerslab/jquery.msg/master/jquery.center.min.js"></script>

  <script src="https://raw.github.com/dreamerslab/jquery.msg/master/jquery.msg.min.js"></script>


<meta charset=utf-8 />
<title>Test Page</title>
</head>
<body>
  <div id="test"></div>
</body>
</html>

<强>的jQuery

jQuery(document).ready(function($){
$.ajax({
  url: "http://www.google.com",
  beforeSend: function ( xhr ) {
      $("#test").html("before send");
    $.msg({
    autoUnblock: false
    });
  },
  success:function(){
    $("#test").html("success");
      $.msg('unblock'); //this will remove the msg box
  },
  error:function(){
     $("#test").html("error");
    $.msg('unblock'); //this will remove the msg box
  }
});
});

这是小提琴:http://jsfiddle.net/qqjhB/1/

在此示例代码中,您将首先进入beforesend块,以便它显示msg框和&amp;然后它将在error块中结束,然后它将删除该msg框。