AJAX question

AJAX question

am 20.04.2008 14:09:42 von sheldonlg

I have a class to export a 2D array to Excel. This works very well when
AJAX is not involved. Basically, I set the title, set the array, and
then invoke the send method which sets the headers and echoes the result
of the string of headers and body that I have built. The user is asked
if he wants to open the file or to save it.

When I try to use it with AJAX involved, using ob_start and
ob_get_contents, it simply gets printed to the screen. If I comment out
those lines in order not to delay output so that it might happen before
the return from AJAX, I get "illegal XML character" for the entire
thing. How can I get this to work using AJAX? I don't want to have to
submit the entire page (bypassing AJAX) because then there would be
significant re-generation time for the page to be redisplayed.

Re: AJAX question

am 20.04.2008 15:08:43 von Jerry Stuckle

sheldonlg wrote:
> I have a class to export a 2D array to Excel. This works very well when
> AJAX is not involved. Basically, I set the title, set the array, and
> then invoke the send method which sets the headers and echoes the result
> of the string of headers and body that I have built. The user is asked
> if he wants to open the file or to save it.
>
> When I try to use it with AJAX involved, using ob_start and
> ob_get_contents, it simply gets printed to the screen. If I comment out
> those lines in order not to delay output so that it might happen before
> the return from AJAX, I get "illegal XML character" for the entire
> thing. How can I get this to work using AJAX? I don't want to have to
> submit the entire page (bypassing AJAX) because then there would be
> significant re-generation time for the page to be redisplayed.
>
>

Try comp.lang.javascript. Figure out what your javascript code is doing
wrong.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: AJAX question

am 20.04.2008 16:27:32 von sheldonlg

Jerry Stuckle wrote:
> sheldonlg wrote:
>> I have a class to export a 2D array to Excel. This works very well
>> when AJAX is not involved. Basically, I set the title, set the array,
>> and then invoke the send method which sets the headers and echoes the
>> result of the string of headers and body that I have built. The user
>> is asked if he wants to open the file or to save it.
>>
>> When I try to use it with AJAX involved, using ob_start and
>> ob_get_contents, it simply gets printed to the screen. If I comment
>> out those lines in order not to delay output so that it might happen
>> before the return from AJAX, I get "illegal XML character" for the
>> entire thing. How can I get this to work using AJAX? I don't want to
>> have to submit the entire page (bypassing AJAX) because then there
>> would be significant re-generation time for the page to be redisplayed.
>>
>>
>
> Try comp.lang.javascript. Figure out what your javascript code is doing
> wrong.
>


No, Jerry, it is not what the Javascript is doing wrong. That AJAX
stuff is working properly for everything else and returning proper
strings that are displayed properly. It is the necessity to write a
file that is the problem here. That is, the interaction of the AJAX
with the php code that tries to write the file. The AJAX captures the
string and that string is displayed. Basically, it seems that the header
settings are ignored. Perhaps, that is the answer. That is, to
redirect the output to where the headers say it should be.

Re: AJAX question

am 20.04.2008 16:32:18 von sheldonlg

sheldonlg wrote:
> Jerry Stuckle wrote:
>> sheldonlg wrote:
>>> I have a class to export a 2D array to Excel. This works very well
>>> when AJAX is not involved. Basically, I set the title, set the
>>> array, and then invoke the send method which sets the headers and
>>> echoes the result of the string of headers and body that I have
>>> built. The user is asked if he wants to open the file or to save it.
>>>
>>> When I try to use it with AJAX involved, using ob_start and
>>> ob_get_contents, it simply gets printed to the screen. If I comment
>>> out those lines in order not to delay output so that it might happen
>>> before the return from AJAX, I get "illegal XML character" for the
>>> entire thing. How can I get this to work using AJAX? I don't want to
>>> have to submit the entire page (bypassing AJAX) because then there
>>> would be significant re-generation time for the page to be redisplayed.
>>>
>>>
>>
>> Try comp.lang.javascript. Figure out what your javascript code is
>> doing wrong.
>>
>
>
> No, Jerry, it is not what the Javascript is doing wrong. That AJAX
> stuff is working properly for everything else and returning proper
> strings that are displayed properly. It is the necessity to write a
> file that is the problem here. That is, the interaction of the AJAX
> with the php code that tries to write the file. The AJAX captures the
> string and that string is displayed. Basically, it seems that the header
> settings are ignored. Perhaps, that is the answer. That is, to
> redirect the output to where the headers say it should be.

I also entered a Javascript question on how to specify the target (as
per your suggestion).

Re: AJAX question

am 20.04.2008 16:34:58 von Jerry Stuckle

sheldonlg wrote:
> Jerry Stuckle wrote:
>> sheldonlg wrote:
>>> I have a class to export a 2D array to Excel. This works very well
>>> when AJAX is not involved. Basically, I set the title, set the
>>> array, and then invoke the send method which sets the headers and
>>> echoes the result of the string of headers and body that I have
>>> built. The user is asked if he wants to open the file or to save it.
>>>
>>> When I try to use it with AJAX involved, using ob_start and
>>> ob_get_contents, it simply gets printed to the screen. If I comment
>>> out those lines in order not to delay output so that it might happen
>>> before the return from AJAX, I get "illegal XML character" for the
>>> entire thing. How can I get this to work using AJAX? I don't want to
>>> have to submit the entire page (bypassing AJAX) because then there
>>> would be significant re-generation time for the page to be redisplayed.
>>>
>>>
>>
>> Try comp.lang.javascript. Figure out what your javascript code is
>> doing wrong.
>>
>
>
> No, Jerry, it is not what the Javascript is doing wrong. That AJAX
> stuff is working properly for everything else and returning proper
> strings that are displayed properly. It is the necessity to write a
> file that is the problem here. That is, the interaction of the AJAX
> with the php code that tries to write the file. The AJAX captures the
> string and that string is displayed. Basically, it seems that the header
> settings are ignored. Perhaps, that is the answer. That is, to
> redirect the output to where the headers say it should be.
>

Your PHP code is working fine - you said so yourself. It's only when
you bring the AJAX (javascript) code into play you have problems.

PHP isn't printing it to the screen - all it does is send the data on to
the web server.

As I said - you need comp.lang.javascript. Your problem is in your AJAX
handling, and that's where AJAX is supported.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: AJAX question

am 20.04.2008 17:53:43 von Paul Lautman

sheldonlg wrote:
>I have a class to export a 2D array to Excel.
I'd be interested in seeing your class. I have been singularly unsuccessful
in getting the PEAR Excel Writer to install.

Re: AJAX question

am 21.04.2008 20:55:58 von Animesh Kumar

Paul Lautman wrote:
> sheldonlg wrote:
>> I have a class to export a 2D array to Excel.
> I'd be interested in seeing your class. I have been singularly unsuccessful
> in getting the PEAR Excel Writer to install.
>
>

Can't you just export a Comma-delimited file and import it in Excel?
That should be do-able without installing any class.

Unless you want to support a bunch of clients who don't want (or don't
know how) to import comma-delimited files in excel.

Best,
Animesh

Re: AJAX question

am 21.04.2008 23:18:25 von Charles Calvert

On Mon, 21 Apr 2008 11:55:58 -0700, Animesh K
wrote in :

>Paul Lautman wrote:
>> sheldonlg wrote:
>>> I have a class to export a 2D array to Excel.
>> I'd be interested in seeing your class. I have been singularly unsuccessful
>> in getting the PEAR Excel Writer to install.
>
>Can't you just export a Comma-delimited file and import it in Excel?
>That should be do-able without installing any class.
>
>Unless you want to support a bunch of clients who don't want (or don't
>know how) to import comma-delimited files in excel.

Every Windows version of Excel (don't know about Mac versions) from 97
on will import a CSV just by opening it via File -> Open. Excel will
also make itself the default handier for .csv files on installation. I
don't see much of an issue there.
--
Charles Calvert | Software Design/Development
Celtic Wolf, Inc. | Project Management
http://www.celticwolf.com/ | Technical Writing
(703) 580-0210 | Research

Re: AJAX question

am 22.04.2008 00:32:28 von sheldonlg

Animesh K wrote:
> Paul Lautman wrote:
>> sheldonlg wrote:
>>> I have a class to export a 2D array to Excel.
>> I'd be interested in seeing your class. I have been singularly
>> unsuccessful in getting the PEAR Excel Writer to install.
>>
>
> Can't you just export a Comma-delimited file and import it in Excel?
> That should be do-able without installing any class.
>
> Unless you want to support a bunch of clients who don't want (or don't
> know how) to import comma-delimited files in excel.
>
> Best,
> Animesh

This is for accounting types. They want an Excel file. Anyway, I found
a way around the problem thanks to another suggestion. The answer was -
"don;t use AJAX for this".

Re: AJAX question

am 22.04.2008 00:35:37 von sheldonlg

Charles Calvert wrote:
> On Mon, 21 Apr 2008 11:55:58 -0700, Animesh K
> wrote in :
>
>> Paul Lautman wrote:
>>> sheldonlg wrote:
>>>> I have a class to export a 2D array to Excel.
>>> I'd be interested in seeing your class. I have been singularly unsuccessful
>>> in getting the PEAR Excel Writer to install.
>> Can't you just export a Comma-delimited file and import it in Excel?
>> That should be do-able without installing any class.
>>
>> Unless you want to support a bunch of clients who don't want (or don't
>> know how) to import comma-delimited files in excel.
>
> Every Windows version of Excel (don't know about Mac versions) from 97
> on will import a CSV just by opening it via File -> Open. Excel will
> also make itself the default handier for .csv files on installation. I
> don't see much of an issue there.

The issue is not the file format. That doesn't matter. The issue is
that is wasn't possible to write to the USER'S machine (with his
permission) when using AJAX. Without AJAX involved, the attempt to
write to the USER'S machine brought up a dialog box requesting
permission. AJAX didn't allow that to happen and couldn't write it
anyway. Remember, we are not talking about writing a file on the server.

Re: AJAX question

am 22.04.2008 10:57:49 von Captain Paralytic

On 21 Apr, 18:55, Animesh K wrote:
> Paul Lautman wrote:
> > sheldonlg wrote:
> >> I have a class to export a 2D array to Excel.
> > I'd be interested in seeing your class. I have been singularly unsuccessful
> > in getting the PEAR Excel Writer to install.
>
> Can't you just export a Comma-delimited file and import it in Excel?
> That should be do-able without installing any class.
>
> Unless you want to support a bunch of clients who don't want (or don't
> know how) to import comma-delimited files in excel.
>
> Best,
> Animesh

Excel does not interpret comma delimited files properly. For example
"John Smith", "0019541234"
will become
Cell A1 = John Smith
Cell B1 = 19541234