Ajax data response by POST

0

Well, I send POST request to server-side to get data (xls). I use fiddler and see binary in response, but Chrome tells me there is a Network Error 0x800c0007.

Server side based on WCF. Here I take HttpResponse, copy Stream from Excel to response.OutputStream, and say response.flush(). It goes without errors.

I see response with 200 Code. But chrome does not react to data.

Probably I use wrong header or need to set up Ajax in different way.

$.ajax({
    url: url,
    method: 'POST',
    type: 'POST',
    data: JSON.stringify({ 'options': options }),
    contentType: 'application/json;charset=utf-8',
    accepts: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
    dataType: 'json',
    mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
    headers: {
        "X-RequestDigest": $("#__REQUESTDIGEST").val(),
        "IF-MATCH": '*',
        "X-HTTP-Method": "POST",
        'mimeType': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
        'accept': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
        'content-type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    },
    error: function (data) {
        console.log("error: ", data);
        a.resolve(null);
    },
    success: function (data, status, headers, config) {
        if (data != null) {
            a.resolve(data);
        }
    }
});
return a.promise();

This is my last attempt. Is it possible to send to server data by Post and have a response with binary?

javascript
ajax
wcf

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0