代码语言:javascript复制
jQuery.ajax({
url: Service1,
type: "GET",
async: false,
beforeSend: function (xhr) {
xhr.setRequestHeader("X-CSRF-Token", "Fetch");
},
success: function (data, textStatus, XMLHttpRequest) {
token = XMLHttpRequest.getResponseHeader("X-CSRF-Token");
}
});
$.ajaxSetup({
cache: false
});
jQuery.ajax({
url: service_url,
async: false,
dataType: "text",
cache: false,
data: filedata,
type: "POST",
beforeSend: function (xhr) {
xhr.setRequestHeader("X-CSRF-Token", token);
xhr.setRequestHeader("Content-Type", "application/text;charset=UTF-8");
},
success: function (odata) {
oDialog.setTitle("File Uploaded");
oDialog.open();
document.location.reload(true);
},
error: function (odata) {
oDialog.setTitle("File NOT Uploaded");
oDialog.open();
document.location.reload(true);
}
});