I am developing a SAPUI5 in order to upload files [mainly XML ]. I have implemented the view using XML views within the WebIDE as well as the corresponding JS controller, which is calling an oData service matched with 'create_stream' method then doing the job of reading the file content.
All is working fine but then I cannot receive the response containing the file content [parsed] from the oData back to my js controller.
Here is my ajax call, actually there are two calls but the first one is used to get the necessary security csrf token only.
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);
}
});
Can anyone find where I am wrong within this flow ?
I think the problem might be in the ajax call, maybe in the parameters or in the way I am getting the data as response from the oData service ?
Or the issue could be whithin the oData create_stream method ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire