1

Here is the situation.

I want to get the data in a excel file setting at the server, to show on the page.

I've searched that ajax can be used to request for a server file, so I tried.

and this is the code:

$.ajax({
    url: 'http://localhost:8080/data.xls',
    method: 'get',
    success: function (e) {
        console.log(e);
    }
});

But the respond get garbled like this: enter image description here

I don't know did I succeed, and what is the data type I got? And if I've succeed, how can I change this type of data to blob?

Thanks a lot!!

Kayla
  • 11
  • 2
  • seems like an issue with the content-type. Can you please provide some more details as to how the response is sent and whether the appropriate content type header was sent in response? Some serverside code would be helpful! – Hussain Ali Akbar Dec 09 '18 at 06:32
  • please post the response headers that you get on success. – Hussain Ali Akbar Dec 09 '18 at 06:33
  • @HussainAliAkbar I checked the network and it didn't really send a network request. I doubt if it is because it was asking for the local file, so it is not really a network request. And there is no server side code, I just run the front-end code with browser-sync. – Kayla Dec 09 '18 at 06:54
  • In that case, it would be helpful if you could post some frontend code. – Hussain Ali Akbar Dec 09 '18 at 07:17
  • A high level search revealed a solution which might be your case as well. https://stackoverflow.com/questions/50007055/fetch-request-to-local-file-not-working . To debug further, some code is required. – Hussain Ali Akbar Dec 09 '18 at 07:19
  • @HussainAliAkbar Thank you very much for comment. I tried it to transform to the XMLHttpRequest Object just now and it finally work! Thanks again. – Kayla Dec 09 '18 at 09:55

0 Answers0