move editor ajax function to native

pull/68/head
Henrique Dias 2016-03-06 13:06:30 +00:00
parent fda5c23ae0
commit 7e27c40841
2 changed files with 25 additions and 26 deletions

File diff suppressed because one or more lines are too long

View File

@ -92,31 +92,30 @@ $(document).on('page:editor', function() {
var data = JSON.stringify($(this).serializeJSON()), var data = JSON.stringify($(this).serializeJSON()),
button = $(this).find("input[type=submit]:focus"); button = $(this).find("input[type=submit]:focus");
$.ajax({ var request = new XMLHttpRequest();
type: 'POST', request.open("POST", window.location);
url: window.location, request.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
data: data, request.setRequestHeader("X-Regenerate", button.data("regenerate"));
headers: { request.setRequestHeader("X-Schedule", button.data("schedule"));
'X-Regenerate': button.data("regenerate"), request.setRequestHeader("X-Content-Type", button.data("type"));
'X-Schedule': button.data("schedule"), request.send(data);
'X-Content-Type': button.data("type") request.onreadystatechange = function() {
}, if (request.readyState == 4) {
dataType: 'json', if (request.status == 200) {
encode: true, notification({
contentType: "application/json; charset=utf-8", text: button.data("message"),
}).done(function(data) { type: 'success',
notification({ timeout: 5000
text: button.data("message"), });
type: 'success', } else {
timeout: 5000 notification({
}); text: 'Something went wrong.',
}).fail(function(data) { type: 'error'
notification({ });
text: 'Something went wrong.', console.log(request.responseText);
type: 'error' }
}); }
console.log(data); }
});
return false; return false;
}); });