473,386 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

AJAX problem with php

I haven't received an answer with my other post, so I am rephrasing it here.

In php I have a 2D array which I "print". The headers force it to be a
file on the user's system. The user receives a pop-up that asks him if
he wants to open it or save it. (Of course, he can simply cancel). The
file I send is in an Excel readable file. This works fine for simple
systems where the page is submitted and then the action is performed by php.

Now for the problem. Using AJAX I have a very complicated page being
displayed that takes a while to build. There are numerous buttons and
"links" on this page. They all operate via AJAX. One of those buttons
is to generate the Excel file. The problem is that if I direct the AJAX
target to a div on the screen, it simply prints and ignores the headers
from php to output to a file. If I don't buffer the output to send it
all at once, then the print statement is not understood by AJAX and I
get an error message about an illegal string.

How do change the AJAX target, and/or what else must I do, so that it
will operate the same as with simple web systems and generate a file and
a popup to the user?
Jun 27 '08 #1
4 2179
sheldonlg schreef:
I haven't received an answer with my other post, so I am rephrasing it
here.

In php I have a 2D array which I "print". The headers force it to be a
file on the user's system. The user receives a pop-up that asks him if
he wants to open it or save it. (Of course, he can simply cancel). The
file I send is in an Excel readable file. This works fine for simple
systems where the page is submitted and then the action is performed by
php.

Now for the problem. Using AJAX I have a very complicated page being
displayed that takes a while to build. There are numerous buttons and
"links" on this page. They all operate via AJAX. One of those buttons
is to generate the Excel file. The problem is that if I direct the AJAX
target to a div on the screen, it simply prints and ignores the headers
from php to output to a file. If I don't buffer the output to send it
all at once, then the print statement is not understood by AJAX and I
get an error message about an illegal string.
Hi,

I fail to see why you use Ajax for this.
The response your PHP script gives you is catched in your HtppXML
Object, which is of course NOT a new window.

So why use Ajax for something it is not suited for?

Why not simply open a new window which loads the content?

<a href="myPHPExcelthingy.php" target="someNewWindow">Excel</a>

Regards,
Erwin Moller
>
How do change the AJAX target, and/or what else must I do, so that it
will operate the same as with simple web systems and generate a file and
a popup to the user?
Jun 27 '08 #2
Erwin Moller wrote:
sheldonlg schreef:
>I haven't received an answer with my other post, so I am rephrasing it
here.

In php I have a 2D array which I "print". The headers force it to be
a file on the user's system. The user receives a pop-up that asks him
if he wants to open it or save it. (Of course, he can simply
cancel). The file I send is in an Excel readable file. This works
fine for simple systems where the page is submitted and then the
action is performed by php.

Now for the problem. Using AJAX I have a very complicated page being
displayed that takes a while to build. There are numerous buttons and
"links" on this page. They all operate via AJAX. One of those buttons
is to generate the Excel file. The problem is that if I direct the
AJAX target to a div on the screen, it simply prints and ignores the
headers from php to output to a file. If I don't buffer the output to
send it all at once, then the print statement is not understood by
AJAX and I get an error message about an illegal string.

Hi,

I fail to see why you use Ajax for this.
The response your PHP script gives you is catched in your HtppXML
Object, which is of course NOT a new window.

So why use Ajax for something it is not suited for?

Why not simply open a new window which loads the content?

<a href="myPHPExcelthingy.php" target="someNewWindow">Excel</a>

Regards,
Erwin Moller
The whole application is built on an AJAX framework. I suppose that for
this one item I could do what you say and go directly to a php file
which pulls in the class to create the array, and then uses the class to
export the array to excel and then returns. No new target window would
be used. It bypasses the framework, but my boss might go along with
this. Thanks. I didn't think of that approach.
Jun 27 '08 #3
well, use a normal GET/POST using a target "_blank" or other, so it
opens in a new window

Jun 27 '08 #4
abaqueiro wrote:
well, use a normal GET/POST using a target "_blank" or other, so it
opens in a new window
It's not as simple as that. The AJAX swallows everything. I had to
work outside of AJAX.
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: bobzimuta | last post by:
I'm creating a simple AJAX library. It's an object that will return an array containing the response text or xml. I'm trying to find a way to assign the response as a property of the object, but...
0
by: melledge | last post by:
Ajax Developers' Day to Kick Off XTech 2006 Conference Industry experts offer insight into next generation of the Web ALEXANDRIA, VIRGINIA, USA - April 25, 2006 - In response to the rapidly...
0
by: melledge | last post by:
Ajax Developers' Day to Kick Off XTech 2006 Conference Industry experts offer insight into next generation of the Web ALEXANDRIA, VIRGINIA, USA - April 25, 2006 - In response to the rapidly...
0
by: melledge | last post by:
Ajax Developers' Day to Kick Off XTech 2006 Conference Industry experts offer insight into next generation of the Web ALEXANDRIA, VIRGINIA, USA - April 25, 2006 - In response to the rapidly...
1
by: www.web20developers.com | last post by:
http://www.web20developers.com http://www.web20developers.com/index.php?option=com_content&task=view... Ajallerix : AJAX, simple, fast Web image gallery demo ; at Novell AJAX -...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.