Created
May 20, 2013 15:21
-
-
Save imbcmdth/5612905 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
AJAXRequest: function(url, action){ | |
/* ---------------------- | |
Small AJAX Library | |
------------------------- */ | |
xhr = new XMLHttpRequest(); | |
xhr.onreadystatechange = function(){ | |
// check if the request is ready and the status is ok | |
if (xhr.readyState === 4 && xhr.status === 200){ | |
action(xhr); | |
} | |
} | |
xhr.open("GET", url, true); // Setup before request | |
xhr.send(null); // Finally request the file | |
}, | |
sendToAFriend: function(){ | |
/* ------------------------------------ | |
Opens a modal with "Send to a Friend" form | |
--------------------------------------- */ | |
document.id('friend-mailer-link').addEvent('click', function(){ | |
jQuery('#myModal').reveal({ | |
animation: 'fade' | |
}); | |
this.AJAXRequest('/friend-mailer/{{article.id}}/', function(xhr){ | |
var grabModal = document.getElementById('myModal-inner'); | |
grabModal.innerHTML = xhr.responseText; | |
}); | |
return false; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment