ajax:beforeSend for jsonp requests don't fire
Working on it
- Need more info
- Working on it
- Answered
in Developing jQuery Core
•
13 years ago
Hi all,
I'm using jQuery to send jsonp request to flickr. My main issue is that I need to sign the url with all its params before sending the request. But at the moment I construct the url, I do not know the random callback function name.
So i tempted to use the beforeSend event, which allow me to handle and modify the url with the second param. My idea is - just before sending the request - to modify on the fly the url in order to add the hashed signature with the right parameters.
The problem is that this event is not fired when using a json data format. So I can't do anything.
I added the line of code on my own and it's working great. Line 4814, just added this :
- // Allow custom headers/mimetypes and early abort
if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) {
// Handle the global AJAX counter
if ( s.global && ! --jQuery.active ) {
jQuery.event.trigger( "ajaxStop" );
}
// close opended socket
xhr.abort();
return false;
}
Is it possible to add this kind of event for json requests ?
Thx
1