0

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
  • If you use firebug, try turn it off - there is bug in some of the latest version, which prevent from firing these events. Commented Jul 23, 2010 at 15:45
  • @yedpodtrzitko, thanks. But still not gold. Commented Jul 23, 2010 at 15:55

2 Answers 2

0

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

Sign up to request clarification or add additional context in comments.

Comments

-2

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

6 Comments

Please elaborate or provide a code sample. Your suggestion is unclear.
Thanks for the elaboration. Please note that ajaxSend is a global callback method. Your recent post could be misleading. However, moving $(document).ajaxSend(...) outside $(document).ready per your original suggestion resolved the problem. Rookie mistake.
added some code. I hope I understood the OP's question right.
@Jason: api.jquery.com/ajaxSend you are right, sorry I thought it was a handmade function.
@Jason McCreary You should consider putting that comment as an answer because it is correct. This answer is not correct at all. Thanks!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.