Skip to content

Instantly share code, notes, and snippets.

@dandean
Created March 29, 2010 18:22
Show Gist options
  • Select an option

  • Save dandean/348208 to your computer and use it in GitHub Desktop.

Select an option

Save dandean/348208 to your computer and use it in GitHub Desktop.
window.__doPostBack = window.__doPostBack.wrap(function(original) {
var name = arguments[1],
argument = arguments[2] || "",
// Convert name to ID. Strip extranious garbage off of the end.
id = name.replace(/\$/g, '_').replace(/_ctl00$/, ''),
element = $(id);
if (element.hasClassName("ajax")) {
// Make the ajax request.
var form = element.up("form"),
// Inject target and argument into data
data = Object.extend(form.serialize(true), {
"__EVENTTARGET": name,
"__EVENTARGUMENT": argument
});
new Ajax.Request(form.action, {
params: data,
onSuccess: function(xhr) {
document.fire("xhr:success", {
transport: xhr,
source: name
});
}
});
} else original(name, argument);
});
/*
TODO:
- Observe "submit" on the page form.
-- If the source is an input of type SUBMIT, IMAGE or BUTTON, or a BUTTON
-- and the source hasClassName("ajax"), stop the event and post async.
- Auto-process response. Convert resonse to JSON on server side.
*/
@renato-caruso
Copy link

fucking off dotnet!!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment