weixin_33696822 2010-07-23 15:42 采纳率: 0%
浏览 94

jQuery和ajaxSend不触发

I set the global ajaxSend callback as below in my $(document).ready function.

 // global AJAX methods
 $(document).ajaxSend(function(e, xhr, settings) {
  alert('here');
    });

However, I am never getting here even though I have several $.ajax() calls that run successfully after the document has loaded and on demand. Yet, here appears when I calling $.post.

Do global methods not call for $.ajax requests? I have not modified the global param, so they should.

I am fine using the beforeSend, but I need access to the url and other request data.

Any ideas would be appreciated as I have yet to find any gotchas from the docs.

  • 写回答

2条回答 默认 最新

  • weixin_33712987 2010-07-23 15:45
    关注

    since it's a callback it doesn't need to be in $(document).ready. It can be a standard function.


    set your callback function in your $.ajax calls and everything will be fine.

    [edit]

    function ajaxSend(data)
    {
    alert('hello');
    }
    
    $.ajax({url: [url],
                type: 'POST',
                cache: false,
                data: oData,
                success: ajaxSend});    
    

    keeping it easy.. :)

    评论

报告相同问题?

悬赏问题

  • ¥15 求TYPCE母转母转接头24PIN线路板图
  • ¥100 国外网络搭建,有偿交流
  • ¥15 高价求中通快递查询接口
  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型