Ruby and jQuery -- $(document).ajaxSend() not modifying the params as expected
Posted
by Jason
on Stack Overflow
See other posts from Stack Overflow
or by Jason
Published on 2010-04-06T20:17:50Z
Indexed on
2010/04/06
20:53 UTC
Read the original article
Hit count: 222
I cannot get jquery's ajaxSend (http://api.jquery.com/ajaxSend/) to properly modify the parameters. I have:
$(document).ajaxSend(function(event, request, settings) {
settings.data = $.deparam(settings.data);
settings.data['random'] = new Date().getTime();
settings.data['_method'] = 'get';
settings.data = $.param(settings.data)
$.log(settings);
});
$(document).ready(function() {
//...snip...
$.ajaxSetup({
data : {
remote : 1,
authenticity_token : encodeURIComponent(AUTH_TOKEN)
}
});
});
The idea here is that we always want 4 param sent across: remote and auth_token always get set properly. However, random and _method (both needed for IE issues) do not get set. Logging settings inside ajaxSend shows me that they are set to settings.data:
"remote=1&authenticity_token=6GA9R_snip_253D&random=1270584905846&_method=get"
but when it gets sent across the wire, I only have the following:
authenticity_token 6GA9R_snip_253D
remote 1
Why in the world is this not working?
© Stack Overflow or respective owner