Skip to content

Instantly share code, notes, and snippets.

@atree
Created December 15, 2012 08:17
Show Gist options
  • Save atree/4292100 to your computer and use it in GitHub Desktop.
Save atree/4292100 to your computer and use it in GitHub Desktop.
I always forget how to create javascript singleton objects.
var obj_ea = new function() {
this.url = 'some_ajax_url.php';
this.submit_actions = function() {
var data = {
'id': 'e04b7291',
'email': $('#email1').val(),
'status': $('#status1').val(),
'email_pre_cust': $('#email4').attr('checked'),
'email_pre_fire': $('#email5').attr('checked'),
'email_approved': $('#email3').attr('checked'),
'email_denied' : $('#email2').attr('checked'),
'expired_date' : $('#expiration').attr('checked')};
$.ajax({
url:this.url,
type:'POST',
data:data,
success: function(response) { rep = JSON.parse(response); if (rep.RELOAD) {location.reload();} }
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment