Hi!
In short: You can't!
A possible way:
Do a HEAD request first, check the content-type as you do, if it's
"usable" data load it with a GET request, if it's "downloadable" data
open the same url in a new window. The browser will see that it is an
oktet-stream and will open download dialog!
Regards,
Mario

PS: My english is also pure!

On 26 Jun., 15:36, jgmaux <[EMAIL PROTECTED]> wrote:
> Ttanks, Liam
>
> Sorry, my english language is very bad......
>
> I'like to receive, via ajax,  a binary data (application/octet-stream)
> from server. And I pass it to the browser for display download window
> dialog......
>
> I suppose that document.write('...') function is only for a text / html
> content. It is right?
> There is any function to write binary content?
>
> Thanks in advance....
>
> Liam Byrne escribió:
>
>
>
> > Maybe I'm missing something, but document.write(result) will only work
> > if the variable result has a value, and I can't see it being set
> > anywhere ?
>
> > Liam
>
> > MrFishKill wrote:
> >> Hi,
>
> >> Sometimes, via AJAX,  I'm getting binary content from a server
> >> (application/octet-stream), other times html-text. When server
> >> response with
> >> binary content  (PDF, EXCEL, etc) I'like to send to user.
> >> It's possible????
>
> >> This is my code:
>
> >> function CNMSubmitAjax(arguments,id_capa, extra_props)
> >> {
> >>    var ret;
> >>    var _msg="";
> >>    $.ajax
> >>    (
> >>        {
> >>               type: "POST",
> >>               url: CNMCONTROLLER,
> >>               cache: false,
> >>               async: ASYNC,
> >>               data: arguments,
> >>               beforeSend: CNMWaitWindowStart(),
> >>               error:  function (o,msg,eoerror)
> >>                       {
> >>                           CNMShowAjaxError(o,msg,eoerror);
> >>                       },
> >>               success: function (msg)
> >>                        {
> >>                            _msg=msg;
> >>                            CNMWaitWindowStop();
> >>                        },
> >>               complete:function (xml_http_request)
> >>               {
> >>                   //Is it binary Type?????
> >>                    var content_type =
> >> xml_http_request.getResponseHeader('Content-Type');
>
> >>                    if (content_type == "application/octet-stream" )
> >>                    {
> >>                         document.write(result);      
> >> <----------------------   Don't work !!!!!  It's possible?
> >>                    }
> >>                    else
> >>                    {
> >>                        .........
> >>                     }
> >>               }
> >>         }
> >>     );
> >> }
>
> >> Thanks in advance....  

Reply via email to