move editor ajax function to native
parent
fda5c23ae0
commit
7e27c40841
File diff suppressed because one or more lines are too long
|
@ -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;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue