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