Created
May 20, 2010 18:01
-
-
Save duncanbeevers/407872 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>xhr status code test</title> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js"></script> | |
<script type="text/javascript"> | |
//<![CDATA[ | |
document.observe('dom:loaded', function() { | |
var body = $$('body')[0], | |
template = new Template("<span class=\"script_example\"><pre class=\"body\">#{body}</pre><button class=\"trigger_script\">Execute</button></span>"), | |
i = 0, new_el; | |
$$('body script').each(function(el){ | |
new_el = new Element('p'); | |
body.insert((new_el.insert(template.evaluate({ body: el.innerHTML, i: i++ })))); | |
}); | |
document.observe('click', function(evt) { | |
var el = evt.element(); | |
if (el.hasClassName('trigger_script')) { | |
eval(el.up('.script_example').down('.body').innerHTML); | |
} | |
}); | |
}); | |
//]]> | |
</script> | |
<style type="text/css"> | |
p { padding: 0.5em; border: 1px solid #d0d0d0; } | |
pre { padding: 0.5em; margin: 0; background-color: #f0f0e0; } | |
button { margin-top: 0.5em; } | |
</style> | |
</head> | |
<body> | |
<script type="text/html"> | |
new Ajax.Request('/rails_success', { | |
on302: function() { | |
console.log("on302 handler fired"); | |
} | |
}); | |
</script> | |
<script type="text/html"> | |
new Ajax.Request('/rails_success', { | |
on302: function() { | |
console.log("on302 handler fired"); | |
}, | |
onComplete: function() { | |
console.log("onComplete handler fired"); | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment