realms-wiki/realms/static/js/main.js
Matthew Scragg e6bc4928c9 Fix #24 #21
WIP commit.  Changed routes to POST/PUT/DELETE on page name endpoint to be more RESTful.
Check wiki dir permissions
Add comments
Add dummy favicon, robots.txt, humans.txt
Remove create.html (wasn't being used)
Fix version command
2014-10-20 17:27:38 -05:00

40 lines
742 B
JavaScript

$(function(){
$(".ajax-form").submit(function(e){
e.preventDefault();
var submitting = 'submitting';
if ($(this).data(submitting)) {
return;
}
$(this).data(submitting, 1);
var action = $(this).attr('action');
var method = $(this).attr('method');
var redirect = $(this).data('redirect');
var data = $(this).serialize();
var req = $.ajax({
type: method,
url: action,
data: data,
dataType: 'json'
});
req.done(function() {
if (redirect) {
location.href = redirect;
}
});
req.fail(function(data, status, error) {
console.log(data);
});
req.always(function() {
$(this).removeData(submitting);
});
});
});