lundi 29 juin 2015

downloading created excel file using jquery from asmx web service

I have a problem that has been driving me crazy. I am trying to create an asmx webservice to create an excel file and download it to the client machine.

I have written an asmx webservice, where I create the excel file perfectly and saveit on the server.then I send back the address of the excel file on the server to the client using this code

    type: "POST",
    url: '/API/Services/',
    data: JSON.stringify(params),
    async: false,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (data) {



In my jquery I call the webservice, it runs, the excel is created and the physical address is returned.

the problem is that I do not know how to download the excel file to the client's machine.

I searched a lot and many posts said that its as easy as writing a window.location.replace(excellAddressOnServer).

However,when I do this, the page is redirected to another one, where the exceladdress is written in the address bar but the page shows an error which says that the address wasn'tundrestood.

The wonder is that when I press enter on the address bar, it starts to download the file without any problem.

what is wrong with my code?

Aucun commentaire:

Enregistrer un commentaire