Skip to content

Instantly share code, notes, and snippets.

@Raynos
Created January 28, 2012 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raynos/1694295 to your computer and use it in GitHub Desktop.
Save Raynos/1694295 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Billing</title>
</head>
<body>
Enter name on credit card: <input type="text" id="ccName" /><br><br>
<button id="submitButton">Submit Payment</button>
<script type="text/javascript" src="js/billing-bundle.js"></script>
</body>
</html>
var Url = require("Url.js").Url,
$ = require("jQuery");
$('#submitButton').click(function() {
var url = new Url('http://bla.com/process/billing');
var creditCardName = $('#ccName').val();
url.addParameter('name', creditCardName);
url.ajax();
}
function log(message) {
console.log((new Date()) + ': ' + message);
}
window.onerror = function(message) {
log('Unhandled error: ' + message);
}
module.exports = { log: log };
var log = require("common.js").log;
function Url(url) {
this.url = url;
}
Url.prototype.addParameter = function(name, value) {
this.url += '?' + name + '=' + value;
};
Url.prototype.ajax = function() {
log('Send ajax to: ' + this.url);
};
module.exports = { Url: Url };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment