记录后在asp.net MVC 3和jQuery [英] record post in asp.net mvc 3 and jquery

查看:95
本文介绍了记录后在asp.net MVC 3和jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是很新的ASP和jQuery,并可能与一些帮助做的。我想用一个Ajax请求记录的时间后请求被发送的数量,但没有得到一个线索从哪里开始。我想这可能是是与一个jQuery.ajaxSetup但我不确定。

Hi I'm quite new to ASP and jQuery and could do with some help. I want to use an Ajax request to record the number of times a post request is sent, but haven't got a clue where to start. I thought it might be something to do with an jQuery.ajaxSetup but am unsure.

如果有人可以帮助或至少点我在正确的方向,将是巨大的。

If anyone could help or a least point me in the right direction that would be great.

推荐答案

您可以使用beforeSend回调:

You could use the beforeSend callback:

var count = 0;

$.ajaxSetup({
    beforeSend: function(jqXHR, settings) {
        if (settings.type == 'POST') {
            count++;
        }

        // Allow only 3 POST AJAX requests for this page 
        // and if there are more abort them
        if (count > 3) {
            return false;
        }
    }
});

这篇关于记录后在asp.net MVC 3和jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆