[jQuery] Re: Download a file from server...

2009-01-23 Thread Nicolas R

I also worked around this by using an iframe, and pointing the form's
(or anchor's) target attribute to that iframe. Some browsers don't
like it when the iframe is set to visibility:hidden or display:none.
If you make it position:absolute;height:0;width:0;border:0; it should
be ok.

Now, I want to know when the 'save file' pop up is displayed to the
user (=> when the server has done processing the user's request).
Apparently, the iframe's load event is not triggered when the server
does not give back any text/html.

Any workaround for this?


[jQuery] Re: Download a file from server...

2009-01-22 Thread AlexDeLarge

Thank you guys for your answers! I really do appreciate them. As soon
as I get back to my problem I'll try some of these suggestions.

Once again, thank you.


[jQuery] Re: Download a file from server...

2009-01-22 Thread Mario Soto

In the post above by Alexandre Plennevaux, the link says how to. :)

On Jan 22, 9:38 am, Mario Soto  wrote:
> It must be using http headers:
>
>         header('Content-Disposition: inline; filename='.
> $filename.'.pdf');
>         header('Content-type: application/x-pdf');
>         echo $pdfData;
>         die();
>
> By example. -
>
> On Jan 22, 3:05 am, Genus Project  wrote:
>
> > or you can do this.
> > 1. your php create the file from your post.
> > 2. return something to the script ($.post) that says you have
> > successfully created the file
> >     or maybe with the filepath in it in json or whichever format it
> > is.
> > 3. redirect your current window to the path of this file.
>
> > But it may show the file as is because browser can usually display a
> > txt file.
>
> > I am not sure how to open up the browser dialog save us box :)
>
> > On Jan 22, 3:46 am, AlexDeLarge 
> > wrote:
>
> > > Hi,
>
> > > I have situation like this: I post certain data with $.post to PHP-
> > > script which is supposed to handle the data, create a file from it and
> > > then trigger browser to open a Save As-dialog. Everything works just
> > > fine except the Save As-dialog, I just can't make it pop-up.
>
> > > For the Save As dialog the PHP-script ha s following statements:
>
> > > header('Content-disposition: attachment; filename=stats.txt');
> > > header('Content-type: text/plain');
> > > readfile('stats.txt');
>
> > > And this just doesn't work through $.post, or at least I can't make it
> > > happen.
>
> > > Is there any way to make this work?


[jQuery] Re: Download a file from server...

2009-01-22 Thread Mario Soto

It must be using http headers:

header('Content-Disposition: inline; filename='.
$filename.'.pdf');
header('Content-type: application/x-pdf');
echo $pdfData;
die();

By example. -


On Jan 22, 3:05 am, Genus Project  wrote:
> or you can do this.
> 1. your php create the file from your post.
> 2. return something to the script ($.post) that says you have
> successfully created the file
>     or maybe with the filepath in it in json or whichever format it
> is.
> 3. redirect your current window to the path of this file.
>
> But it may show the file as is because browser can usually display a
> txt file.
>
> I am not sure how to open up the browser dialog save us box :)
>
> On Jan 22, 3:46 am, AlexDeLarge 
> wrote:
>
> > Hi,
>
> > I have situation like this: I post certain data with $.post to PHP-
> > script which is supposed to handle the data, create a file from it and
> > then trigger browser to open a Save As-dialog. Everything works just
> > fine except the Save As-dialog, I just can't make it pop-up.
>
> > For the Save As dialog the PHP-script ha s following statements:
>
> > header('Content-disposition: attachment; filename=stats.txt');
> > header('Content-type: text/plain');
> > readfile('stats.txt');
>
> > And this just doesn't work through $.post, or at least I can't make it
> > happen.
>
> > Is there any way to make this work?


[jQuery] Re: Download a file from server...

2009-01-22 Thread Genus Project

or you can do this.
1. your php create the file from your post.
2. return something to the script ($.post) that says you have
successfully created the file
or maybe with the filepath in it in json or whichever format it
is.
3. redirect your current window to the path of this file.

But it may show the file as is because browser can usually display a
txt file.

I am not sure how to open up the browser dialog save us box :)



On Jan 22, 3:46 am, AlexDeLarge 
wrote:
> Hi,
>
> I have situation like this: I post certain data with $.post to PHP-
> script which is supposed to handle the data, create a file from it and
> then trigger browser to open a Save As-dialog. Everything works just
> fine except the Save As-dialog, I just can't make it pop-up.
>
> For the Save As dialog the PHP-script ha s following statements:
>
> header('Content-disposition: attachment; filename=stats.txt');
> header('Content-type: text/plain');
> readfile('stats.txt');
>
> And this just doesn't work through $.post, or at least I can't make it
> happen.
>
> Is there any way to make this work?


[jQuery] Re: Download a file from server...

2009-01-21 Thread Ricardo Tomasi

You could create a hidden iframe and point it to the file, wouldn't
that work?

On Jan 22, 5:28 am, Alexandre Plennevaux 
wrote:
> Well, AFAIK It HAS to be triggered by a click event on a A anchor, so,
> just make sure your onclick handler returns true.
>
> For the "force download" functionality, this writeup of mine might help you:
>
> http://www.pixeline.be/blog/2009/php-force-download-script-convert-ur...
>
> On Thu, Jan 22, 2009 at 2:30 AM, MorningZ  wrote:
>
> > You don't want AJAX in this situation have the page post like
> > normal and do what you lay out above...  AJAX is *not* the solution to
> > every problem
>
> > On Jan 21, 6:46 pm, AlexDeLarge 
> > wrote:
> >> Hi,
>
> >> I have situation like this: I post certain data with $.post to PHP-
> >> script which is supposed to handle the data, create a file from it and
> >> then trigger browser to open a Save As-dialog. Everything works just
> >> fine except the Save As-dialog, I just can't make it pop-up.
>
> >> For the Save As dialog the PHP-script ha s following statements:
>
> >> header('Content-disposition: attachment; filename=stats.txt');
> >> header('Content-type: text/plain');
> >> readfile('stats.txt');
>
> >> And this just doesn't work through $.post, or at least I can't make it
> >> happen.
>
> >> Is there any way to make this work?


[jQuery] Re: Download a file from server...

2009-01-21 Thread Alexandre Plennevaux

Well, AFAIK It HAS to be triggered by a click event on a A anchor, so,
just make sure your onclick handler returns true.

For the "force download" functionality, this writeup of mine might help you:

http://www.pixeline.be/blog/2009/php-force-download-script-convert-url-to-localpath/




On Thu, Jan 22, 2009 at 2:30 AM, MorningZ  wrote:
>
> You don't want AJAX in this situation have the page post like
> normal and do what you lay out above...  AJAX is *not* the solution to
> every problem
>
> On Jan 21, 6:46 pm, AlexDeLarge 
> wrote:
>> Hi,
>>
>> I have situation like this: I post certain data with $.post to PHP-
>> script which is supposed to handle the data, create a file from it and
>> then trigger browser to open a Save As-dialog. Everything works just
>> fine except the Save As-dialog, I just can't make it pop-up.
>>
>> For the Save As dialog the PHP-script ha s following statements:
>>
>> header('Content-disposition: attachment; filename=stats.txt');
>> header('Content-type: text/plain');
>> readfile('stats.txt');
>>
>> And this just doesn't work through $.post, or at least I can't make it
>> happen.
>>
>> Is there any way to make this work?


[jQuery] Re: Download a file from server...

2009-01-21 Thread MorningZ

You don't want AJAX in this situation have the page post like
normal and do what you lay out above...  AJAX is *not* the solution to
every problem

On Jan 21, 6:46 pm, AlexDeLarge 
wrote:
> Hi,
>
> I have situation like this: I post certain data with $.post to PHP-
> script which is supposed to handle the data, create a file from it and
> then trigger browser to open a Save As-dialog. Everything works just
> fine except the Save As-dialog, I just can't make it pop-up.
>
> For the Save As dialog the PHP-script ha s following statements:
>
> header('Content-disposition: attachment; filename=stats.txt');
> header('Content-type: text/plain');
> readfile('stats.txt');
>
> And this just doesn't work through $.post, or at least I can't make it
> happen.
>
> Is there any way to make this work?