开发者

jQuery and ajaxSend not firing

开发者 https://www.devze.com 2023-01-08 08:55 出处:网络
I set the global ajaxSend callback as below in my $(document).ready function. // global AJAX methods $(document).ajaxSend(function(e, xhr, settings) {

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 par开发者_JAVA技巧am, 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.


Are you using IE by the way? If so it caches ajax calls which are not posts.

see this link: jQuery AJAX request failing in IE


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.. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消