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 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的