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,
contentType: "application/json; charset=utf-8",
}).done(function(data) {
notification({ notification({
text: button.data("message"), text: button.data("message"),
type: 'success', type: 'success',
timeout: 5000 timeout: 5000
}); });
}).fail(function(data) { } else {
notification({ notification({
text: 'Something went wrong.', text: 'Something went wrong.',
type: 'error' type: 'error'
}); });
console.log(data); console.log(request.responseText);
}); }
}
}
return false; return false;
}); });