move jquery ajax to XMLHttpRequest
parent
8043610590
commit
fda5c23ae0
File diff suppressed because one or more lines are too long
|
@ -234,15 +234,17 @@ $(document).on('page:browse', function() {
|
|||
filename = window.location.pathname.replace("/admin/browse/", "") + '/' + filename;
|
||||
}
|
||||
|
||||
var content = '{"filename": "' + filename + '"}';
|
||||
var content = {
|
||||
filename: filename
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
type: 'PUT',
|
||||
url: rename.url,
|
||||
data: content,
|
||||
dataType: 'json',
|
||||
encode: true
|
||||
}).done(function(data) {
|
||||
var request = new XMLHttpRequest();
|
||||
request.open("PUT", rename.url);
|
||||
request.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
||||
request.send(JSON.stringify(content));
|
||||
request.onreadystatechange = function() {
|
||||
if (request.readyState == 4) {
|
||||
if (request.status == 200) {
|
||||
$.pjax({
|
||||
url: window.location.pathname,
|
||||
container: '#content'
|
||||
|
@ -252,13 +254,15 @@ $(document).on('page:browse', function() {
|
|||
type: 'success',
|
||||
timeout: 5000
|
||||
});
|
||||
}).fail(function(data) {
|
||||
} else {
|
||||
notification({
|
||||
text: 'Something went wrong.',
|
||||
type: 'error'
|
||||
});
|
||||
console.log(data);
|
||||
});
|
||||
console.log(request.responseText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
@ -306,31 +310,19 @@ $(document).on('page:browse', function() {
|
|||
request.send(JSON.stringify({
|
||||
command: value
|
||||
}));
|
||||
request.onreadystatechange = function() {
|
||||
if (request.readyState == 4) {
|
||||
if (request.status == 200) {
|
||||
|
||||
/*$.ajax({
|
||||
type: 'POST',
|
||||
url: window.location.pathname,
|
||||
data: content,
|
||||
dataType: 'json',
|
||||
encode: true,
|
||||
}).done(function(data) {
|
||||
notification({
|
||||
text: "File created successfully.",
|
||||
type: 'success',
|
||||
timeout: 5000
|
||||
});
|
||||
|
||||
$.pjax({
|
||||
url: data.Location,
|
||||
container: '#content'
|
||||
})
|
||||
}).fail(function(data) {
|
||||
} else {
|
||||
notification({
|
||||
text: 'Something went wrong.',
|
||||
type: 'error'
|
||||
});
|
||||
console.log(data);
|
||||
}); */
|
||||
console.log(request.responseText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue