473,320 Members | 1,719 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,320 software developers and data experts.

Passing a lot of data

I could use a little help here. I have goodled with not much luck. I
have been at this for a bit and would appreciate suggestions.

I have a form (A.php) that collects a lot of data. When I post it, I
gather the data (in A_process.php) and insert/update into a database
using php and mysql. I then redirect back to the original page (A.php)
using a "header" command. This all works fine.

The customer would like me to put in "print" button that would bring up
a printable version in another window (B.php). The problem is that I
want to do this while keeping all the data displayed on the current window.

I have tried creating a json string so that all I would need is
json_decode on the php side to convert it into an array and build the
page. I then did a window.open(). The result was that the string was
too long for the URI for the server. (It would most likely also get the
same problem using AJAX since the parameters are in the URI). Using AJAX
to receive a lot of data from the server is easy. It seems to be very
hard going in the other direction. So, I am looking for suggestions.

I am considering doing this entirely in php by changing the print button
from type "button" to type "submit", testing in the target (processing,
A_process.php) file that it was the print button that sent it, creating
a session variable , and then opening a new window (B.php). In that
window I could read the session variable and destroy it. (I can't just
target to the new window (B.php), because I need to keep the processing
page for database submission and returning to an empty generating page
in the original window (A.php).)

I guess that this method might work, but there must be a better,
simpler, and more straightforward solution somewhere.
Nov 4 '08 #1
13 3319
On Nov 4, 8:30 am, sheldonlg <sheldonlgwrote:
<snip>
... The result was that the string was
too long for the URI for the server. (It would most likely also get the
same problem using AJAX since the parameters are in the URI). Using AJAX
to receive a lot of data from the server is easy. It seems to be very
hard going in the other direction. So, I am looking for suggestions.
This is not really a JS problem per se. But a limitation of URI size.
You should use POST instead of GET so that the data is transferred in
the HTTP body instead of the URI.
Nov 4 '08 #2
On Nov 3, 7:30*pm, sheldonlg <sheldonlgwrote:
I could use a little help here. *I have goodled with not much luck. *I
have been at this for a bit and would appreciate suggestions.

I have a form (A.php) that collects a lot of data. *When I post it, I
gather the data (in A_process.php) and insert/update into a database
using php and mysql. *I then redirect back to the original page (A.php)
using a "header" command. *This all works fine.
Not a command as such, but okay.
>
The customer would like me to put in "print" button that would bring up
Did you point out that there is already a "print" button (or at least
file menu item) on the browser?
a printable version in another window (B.php). *The problem is that I
want to do this while keeping all the data displayed on the current window.
That is the "print preview" file menu item (in most browsers.)
>
I have tried creating a json string so that all I would need is
[snip]

Just create a print media style sheet.
Nov 4 '08 #3
slebetman wrote:
On Nov 4, 8:30 am, sheldonlg <sheldonlgwrote:
><snip>
... The result was that the string was
too long for the URI for the server. (It would most likely also get the
same problem using AJAX since the parameters are in the URI). Using AJAX
to receive a lot of data from the server is easy. It seems to be very
hard going in the other direction. So, I am looking for suggestions.
This is not really a JS problem per se. But a limitation of URI size.
You should use POST instead of GET so that the data is transferred in
the HTTP body instead of the URI.
Uh, I **DO** have it as POST. The problem is that that I don't want to
leave the page and so want to do it via Javascript/AJAX. In those, you
pass the values in the URI to the server php from the javascript. The
post is for when I process the page to do the database work.
Nov 4 '08 #4
David Mark wrote:
On Nov 3, 7:30 pm, sheldonlg <sheldonlgwrote:
>I could use a little help here. I have goodled with not much luck. I
have been at this for a bit and would appreciate suggestions.

I have a form (A.php) that collects a lot of data. When I post it, I
gather the data (in A_process.php) and insert/update into a database
using php and mysql. I then redirect back to the original page (A.php)
using a "header" command. This all works fine.

Not a command as such, but okay.
>The customer would like me to put in "print" button that would bring up

Did you point out that there is already a "print" button (or at least
file menu item) on the browser?
>a printable version in another window (B.php). The problem is that I
want to do this while keeping all the data displayed on the current window.

That is the "print preview" file menu item (in most browsers.)
>I have tried creating a json string so that all I would need is

[snip]

Just create a print media style sheet.
One problem that I forgot to mention (sorry) is that the page is fixed
size and so only the unscrolled part that appears on the screen is what
prints. That is why a "print" button is needed to generated a page not
so limited. The actual printing is still done with file/print.
Nov 4 '08 #5
On Nov 3, 11:05*pm, sheldonlg <sheldonlgwrote:
David Mark wrote:
On Nov 3, 7:30 pm, sheldonlg <sheldonlgwrote:
I could use a little help here. *I have goodled with not much luck. *I
have been at this for a bit and would appreciate suggestions.
I have a form (A.php) that collects a lot of data. *When I post it, I
gather the data (in A_process.php) and insert/update into a database
using php and mysql. *I then redirect back to the original page (A.php)
using a "header" command. *This all works fine.
Not a command as such, but okay.
The customer would like me to put in "print" button that would bring up
Did you point out that there is already a "print" button (or at least
file menu item) on the browser?
a printable version in another window (B.php). *The problem is that I
want to do this while keeping all the data displayed on the current window.
That is the "print preview" file menu item (in most browsers.)
I have tried creating a json string so that all I would need is
[snip]
Just create a print media style sheet.

One problem that I forgot to mention (sorry) is that the page is fixed
size and so only the unscrolled part that appears on the screen is what
prints.
In other words, you used CSS to change the flow of the page in some
way that is not advantageous to printing.
That is why a "print" button is needed to generated a page not
so limited. *The actual printing is still done with file/print.
No, you should override what you did for the screen in a print media
style sheet (e.g. change an overflow:auto rule to overflow:visible.)
Nov 4 '08 #6
On Nov 4, 12:03 pm, sheldonlg <sheldonlgwrote:
slebetman wrote:
On Nov 4, 8:30 am, sheldonlg <sheldonlgwrote:
<snip>
... The result was that the string was
too long for the URI for the server. (It would most likely also get the
same problem using AJAX since the parameters are in the URI). Using AJAX
to receive a lot of data from the server is easy. It seems to be very
hard going in the other direction. So, I am looking for suggestions.
This is not really a JS problem per se. But a limitation of URI size.
You should use POST instead of GET so that the data is transferred in
the HTTP body instead of the URI.

Uh, I **DO** have it as POST. The problem is that that I don't want to
leave the page and so want to do it via Javascript/AJAX. In those, you
pass the values in the URI to the server php from the javascript.
Not necessarily, AJAX can either do a GET or POST. My advice to you is
to use a POST:

var request = new XMLHttpRequest();
request.open('POST', 'http://url/path', true);
request.send('var1=hello&var2=goodbye&var3=blah%20 blah');

Nov 4 '08 #7
On Nov 4, 1:04 pm, slebetman <slebet...@gmail.comwrote:
On Nov 4, 12:03 pm, sheldonlg <sheldonlgwrote:
slebetman wrote:
On Nov 4, 8:30 am, sheldonlg <sheldonlgwrote:
><snip>
>... The result was that the string was
>too long for the URI for the server. (It would most likely also get the
>same problem using AJAX since the parameters are in the URI). Using AJAX
>to receive a lot of data from the server is easy. It seems to be very
>hard going in the other direction. So, I am looking for suggestions.
This is not really a JS problem per se. But a limitation of URI size.
You should use POST instead of GET so that the data is transferred in
the HTTP body instead of the URI.
Uh, I **DO** have it as POST. The problem is that that I don't want to
leave the page and so want to do it via Javascript/AJAX. In those, you
pass the values in the URI to the server php from the javascript.

Not necessarily, AJAX can either do a GET or POST. My advice to you is
to use a POST:

...
Sorry, incomplete code what I meant was:

var request = new XMLHttpRequest();
request.open('POST', 'http://url/path', true);
request.send('var1=hello&var2=goodbye&var3=blah%20 blah');
/* ^
* |
* see, you can send as large a string as you like
* in the request body if you use POST.
*/
request.onreadystatechange = function() {
if (request.readyState == 4) {
updatePageWith(request);
}
}
Nov 4 '08 #8
slebetman wrote:
On Nov 4, 12:03 pm, sheldonlg <sheldonlgwrote:
>slebetman wrote:
>>On Nov 4, 8:30 am, sheldonlg <sheldonlgwrote:
<snip>
... The result was that the string was
too long for the URI for the server. (It would most likely also get the
same problem using AJAX since the parameters are in the URI). Using AJAX
to receive a lot of data from the server is easy. It seems to be very
hard going in the other direction. So, I am looking for suggestions.
This is not really a JS problem per se. But a limitation of URI size.
You should use POST instead of GET so that the data is transferred in
the HTTP body instead of the URI.
Uh, I **DO** have it as POST. The problem is that that I don't want to
leave the page and so want to do it via Javascript/AJAX. In those, you
pass the values in the URI to the server php from the javascript.

Not necessarily, AJAX can either do a GET or POST. My advice to you is
to use a POST:

var request = new XMLHttpRequest();
request.open('POST', 'http://url/path', true);
request.send('var1=hello&var2=goodbye&var3=blah%20 blah');
The request-URI is too large

Nov 4 '08 #9
slebetman wrote:
On Nov 4, 1:04 pm, slebetman <slebet...@gmail.comwrote:
>On Nov 4, 12:03 pm, sheldonlg <sheldonlgwrote:
>>slebetman wrote:
On Nov 4, 8:30 am, sheldonlg <sheldonlgwrote:
<snip>
... The result was that the string was
too long for the URI for the server. (It would most likely also get the
same problem using AJAX since the parameters are in the URI). Using AJAX
to receive a lot of data from the server is easy. It seems to be very
hard going in the other direction. So, I am looking for suggestions.
This is not really a JS problem per se. But a limitation of URI size.
You should use POST instead of GET so that the data is transferred in
the HTTP body instead of the URI.
Uh, I **DO** have it as POST. The problem is that that I don't want to
leave the page and so want to do it via Javascript/AJAX. In those, you
pass the values in the URI to the server php from the javascript.
Not necessarily, AJAX can either do a GET or POST. My advice to you is
to use a POST:

...

Sorry, incomplete code what I meant was:

var request = new XMLHttpRequest();
request.open('POST', 'http://url/path', true);
request.send('var1=hello&var2=goodbye&var3=blah%20 blah');
/* ^
* |
* see, you can send as large a string as you like
* in the request body if you use POST.
*/
request.onreadystatechange = function() {
if (request.readyState == 4) {
updatePageWith(request);
}
}
Same thing.

Request-URI Too Large
The requested URL's length exceeds the capacity limit for this server.
Nov 4 '08 #10
SAM
Le 11/4/08 5:05 AM, sheldonlg a écrit :
David Mark wrote:
>[snip]

Just create a print media style sheet.

One problem that I forgot to mention (sorry) is that the page is fixed
size and so only the unscrolled part that appears on the screen is what
prints. That is why a "print" button is needed to generated a page not
so limited.
Did you read what David told ?

use a PRINT MEDIA Style Sheet
^^^^^^^^^^^

This print stylesheet will fixe the height of the div of datas to 'auto'

<style type="text/css">
#datas { height: 400px; overflow: auto; }
</style>
<style type="text/css" media="print">
body { background: none; color: black; }
#datas { height: auto; overflow: none; }
</style>

The actual printing is still done with file/print.

And ?
what's the difference with function print ?

When printing via menu or function,
the stylesheet for printing will be used and, normaly, all datas will be
- shown in preview
- printed on paper

--
sm
Nov 4 '08 #11
SAM
Le 11/4/08 11:58 AM, sheldonlg a écrit :
>
Request-URI Too Large
The requested URL's length exceeds the capacity limit for this server.
Have a look here :
<http://www.captain.at/howto-ajax-form-post-request.php>
and fill the 2 textareas with a lot of datas
(I tried with 80.000 characters in each one)

Tey set a variable to contain all parameters

var params = '', f = document.forms[0].elements;
for(var i=0, n=f.length-1; i<n; i++)
params += f[i].name+'='+encodeURI(f[i].value)+'&';
params += f[f.length-1].name+'='+encodeURI(f[f.length-1].value);


request.open('POST', 'http://url/path', true);
request.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");
request.setRequestHeader("Content-length", params.length);
request.setRequestHeader("Connection", "close");
request.send( params );

--
sm
Nov 4 '08 #12
SAM wrote:
Le 11/4/08 11:58 AM, sheldonlg a écrit :
>>
Request-URI Too Large
The requested URL's length exceeds the capacity limit for this server.

Have a look here :
<http://www.captain.at/howto-ajax-form-post-request.php>
and fill the 2 textareas with a lot of datas
(I tried with 80.000 characters in each one)

Tey set a variable to contain all parameters

var params = '', f = document.forms[0].elements;
for(var i=0, n=f.length-1; i<n; i++)
params += f[i].name+'='+encodeURI(f[i].value)+'&';
params += f[f.length-1].name+'='+encodeURI(f[f.length-1].value);


request.open('POST', 'http://url/path', true);
request.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");
request.setRequestHeader("Content-length", params.length);
request.setRequestHeader("Connection", "close");
request.send( params );
I cut and pasted this exact code into place and it still gave the same
message. It was also significantly less than 80,000 characters. It was
only 6106 characters. The alert I put in to show what params was also
looked quite good.

Here is what I pasted in:
var params = '', f = document.forms[0].elements;
for(var i=0, n=f.length-1; i<n; i++)
params += f[i].name+'='+encodeURI(f[i].value)+'&';
params += f[f.length-1].name+'='+encodeURI(f[f.length-1].value);
alert (params.length);
alert ( params);
var request = new XMLHttpRequest();
request.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");
request.setRequestHeader("Content-length", params.length);
request.setRequestHeader("Connection", "close");
request.send(params);
}
Nov 4 '08 #13
SAM
Le 11/4/08 6:43 PM, sheldonlg a écrit :
SAM wrote:
>Le 11/4/08 11:58 AM, sheldonlg a écrit :
>>>
Request-URI Too Large
The requested URL's length exceeds the capacity limit for this server.

Have a look here :
<http://www.captain.at/howto-ajax-form-post-request.php>

Tey set a variable to contain all parameters
(...)
I cut and pasted this exact code into place
this "exact" code above could be not good (no tested)
Try to use and adapt to your case this of the given link
and it still gave the same message.
It was also significantly less than 80,000 characters. It was
only 6106 characters. The alert I put in to show what params was also
looked quite good.
then ... I don't know what coud be wrong
Here is what I pasted in:
var params = '', f = document.forms[0].elements;
This loop is only an example,
it is only available for text-fields an text-windows
(input type=text and textarea)
for(var i=0, n=f.length-1; i<n; i++)
params += f[i].name+'='+encodeURI(f[i].value)+'&';
params += f[f.length-1].name+'='+encodeURI(f[f.length-1].value);
alert (params.length);
alert ( params);
var request = new XMLHttpRequest();
some little things are missing here (suppose you didn't paste them ?)
request.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");
request.setRequestHeader("Content-length", params.length);
request.setRequestHeader("Connection", "close");
request.send(params);
}

--
sm
Nov 4 '08 #14

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

Similar topics

8
by: Alex Vinokur | last post by:
Various forms of argument passing ================================= C/C++ Performance Tests ======================= Using C/C++ Program Perfometer...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
3
by: Simon Harvey | last post by:
Hi, In my application I get lots of different sorts of information from databases. As such, a lot of information is stored in DataSets and DataTable objects. Up until now, I have been passing...
9
by: Just Me | last post by:
PARAFORMAT2 is a structure that SendMessage will return stuff in. Is the "ref" correct or since only a pointer is being passed should it be by value? Suppose I was passing data rather then...
3
by: Marc Castrechini | last post by:
First off this is a great reference for passing data between the Data Access and Business Layers:...
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
12
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
7
by: TS | last post by:
I was under the assumption that if you pass an object as a param to a method and inside that method this object is changed, the object will stay changed when returned from the method because the...
3
by: DaTurk | last post by:
If I call this method, and pass it a byte by ref, and initialize another byte array, set the original equal to it, and then null the reference, why is the original byte array not null as well? I...
3
by: iu2 | last post by:
Hi all, I need your professional opinion about this. It is more a general programming dilemma rather then a C++ one, but since the project I write is in C++... We handle big structs of data....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.