Re: [PHP] JS alert that links to a file
Hey all, With LinuxMan's help I got this working. It was a bit tricky as it's an AJAX environment, but what I did was create a separate page with code similar to what he has below and then call it from the JS side and it works great. Thanks all, and especially LinuxManMikeC for the key! Skip Skip Evans wrote: LinuxManMikeC wrote: Okay, right, I remember this. But it has to be in it's own file, otherwise you get the 'headers already sent error', right? Is there any way around that? Any way to get it right at the end of where the file is created??? Thanks! Skip -- Skip Evans Big Sky Penguin, LLC 503 S Baldwin St, #1 Madison WI 53703 608.250.2720 http://bigskypenguin.com Those of you who believe in telekinesis, raise my hand. -- Kurt Vonnegut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] JS alert that links to a file
Skip Evans wrote: LinuxManMikeC wrote: Okay, right, I remember this. But it has to be in it's own file, otherwise you get the 'headers already sent error', right? Is there any way around that? Any way to get it right at the end of where the file is created??? Thanks! Skip No, what he gave as an example was just right. only if you try calling header() after you echo something will it give you the header's already sent error. -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] JS alert that links to a file
LinuxManMikeC wrote: Okay, right, I remember this. But it has to be in it's own file, otherwise you get the 'headers already sent error', right? Is there any way around that? Any way to get it right at the end of where the file is created??? Thanks! Skip -- Skip Evans Big Sky Penguin, LLC 503 S Baldwin St, #1 Madison WI 53703 608.250.2720 http://bigskypenguin.com Those of you who believe in telekinesis, raise my hand. -- Kurt Vonnegut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] JS alert that links to a file
On Sun, Jul 26, 2009 at 8:55 PM, Skip Evans wrote: > Okay, I know I've done this before, but now I'm blanking out. > > I have code that creates a CSV file, and when it's done I want a JS alert to > pop up and let them save the file. > > Isn't this some kind of alert() type call on the JS side??? > > I know I've done this before and I've been on Google an hour now! > > -- > > Skip Evans > Big Sky Penguin, LLC > 503 S Baldwin St, #1 > Madison WI 53703 > 608.250.2720 > http://bigskypenguin.com > > Those of you who believe in > telekinesis, raise my hand. > -- Kurt Vonnegut > If I understand you correctly, you have PHP code (lets call it makecsv.php) that makes a CSV file and returns it to the user. When the user visits the script makecsv.php you want them to be prompted to save the CSV file you just generated. If that is what you meant, this is not a JavaScript thing. Just set the Content-type and Content-Disposition headers in your PHP script. The browser will then bring up a "Save as" dialog box when it receives the output from the script. http://us.php.net/manual/en/function.header.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] JS alert that links to a file
On Sun, Jul 26, 2009 at 09:55:14PM -0500, Skip Evans wrote: > Okay, I know I've done this before, but now I'm blanking out. > > I have code that creates a CSV file, and when it's done I want > a JS alert to pop up and let them save the file. > > Isn't this some kind of alert() type call on the JS side??? > > I know I've done this before and I've been on Google an hour now! Not sure I understand your question, but there is a function called alert() in javascript. It opens a window with your error message in it. I don't know of a way to trigger this from PHP, since PHP is server-side and Javascript is client-side. You might be able to have javascript scan for the existence/closing of the file in question and then alert the user. Or you could have PHP, when the file is complete, launch a new page which contains the javascript code to alert the user. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php