Skip to content

Instantly share code, notes, and snippets.

@weerd
Created October 21, 2014 03:14
Show Gist options
  • Save weerd/a558e1543594f03c277d to your computer and use it in GitHub Desktop.
Save weerd/a558e1543594f03c277d to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var makeRequest = function (url, callback) {
// Make the request with the provided url
var data = 10; // simulated data from the server
callback(data);
};
var obj = {
someValue: 20,
loadData: function (data) {
var sum = this.someValue + data;
alert(sum);
},
prepareRequest: function () {
var url = 'http://numberservice.com';
makeRequest(url, this.loadData.bind(this));
}
};
</script>
<script id="jsbin-source-javascript" type="text/javascript">var makeRequest = function (url, callback) {
// Make the request with the provided url
var data = 10; // simulated data from the server
callback(data);
};
var obj = {
someValue: 20,
loadData: function (data) {
var sum = this.someValue + data;
alert(sum);
},
prepareRequest: function () {
var url = 'http://numberservice.com';
makeRequest(url, this.loadData.bind(this));
}
};
</script></body>
</html>
var makeRequest = function (url, callback) {
// Make the request with the provided url
var data = 10; // simulated data from the server
callback(data);
};
var obj = {
someValue: 20,
loadData: function (data) {
var sum = this.someValue + data;
alert(sum);
},
prepareRequest: function () {
var url = 'http://numberservice.com';
makeRequest(url, this.loadData.bind(this));
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment