Created
March 16, 2020 19:02
-
-
Save ijt/761c82d9ab47d76d7d28142caf5371e6 to your computer and use it in GitHub Desktop.
Intercept Ajax calls and make them do something else
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
<html> | |
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> | |
</head> | |
<body> | |
<div id="d">nothing here yet</div> | |
<script> | |
var send = XMLHttpRequest.prototype.send; | |
XMLHttpRequest.prototype.send = function(body) { | |
Object.defineProperty(this, 'responseText', { writable: true }); | |
this.responseText = '' + Date(); | |
this.onload(); | |
}; | |
$('#d').load('http://example.com/this/wont/really/be/loaded'); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment