Skip to content

Instantly share code, notes, and snippets.

@speedupmate
Last active September 14, 2016 07:39
Show Gist options
  • Save speedupmate/eddadf15541078437b8dc09b490492ec to your computer and use it in GitHub Desktop.
Save speedupmate/eddadf15541078437b8dc09b490492ec to your computer and use it in GitHub Desktop.
// for prototype.js http://api.prototypejs.org/ajax/Ajax/Responders/
// same can be done with http://api.jquery.com/Ajax_Events/
Ajax.Responders.register({
onCreate: function(obj){
//listen all ajax calls
if(obj.parameters.something) {
//find your ajax call from the haystack of all calls, by url or by some param whatever fits
if(obj.parameters.something === 'your condition'){
if(your.elements){
var names = your.elements.pluck('name');
var values = your.elements.pluck('value');
for(var x=0; x < names.length; x++) {
obj.parameters[names[x]] = values[x];
}
obj.options.postBody = Object.toQueryString(obj.parameters);
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment