传递大量数据 [英] Passing a lot of data

查看:66
本文介绍了传递大量数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在这里使用一点帮助。我没有太多运气。我已经花了一些时间来讨论这个问题,并希望得到一些建议。


我有一个收集大量数据的表单(A.php)。当我发布它时,我将收集数据(在A_process.php中)并使用php和mysql将数据插入/更新到
。然后我使用标题重定向回原始页面(A.php)

命令。一切正常。


客户希望我输入打印字样。按钮会在另一个窗口(B.php)中显示

可打印版本。问题是我想要在保持所有数据显示在当前窗口的同时执行此操作。


我尝试创建一个json字符串以便所有我需要在php端将

json_decode转换为数组并构建

页面。然后我做了一个window.open()。结果是字符串对于服务器的URI来说太长了。 (由于参数在URI中,因此使用AJAX很可能也会得到相同的问题)。使用AJAX

从服务器接收大量数据很容易。这似乎很难在另一个方向上进行。所以,我正在寻找建议。


我正在考虑通过更改打印按钮完全在php中完成这个工作

来自类型按钮键入submit,在目标(处理,
A_process.php)文件中测试它是发送它的打印按钮,创建

a会话变量,以及然后打开一个新窗口(B.php)。在那个

窗口中,我可以读取会话变量并销毁它。 (我不能只是将
定位到新窗口(B.php),因为我需要保持处理

页面以进行数据库提交并返回空在原始窗口(A.php)中生成页面

。)


我想这个方法可能有效,但必须有更好的,

更简单,更直接的解决方案。

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.

推荐答案

11月4日上午8:30,sheldonlg< sheldonlgwrote:
On Nov 4, 8:30 am, sheldonlg <sheldonlgwrote:

< snip>

...结果是字符串对于URI来说太长了

为服务器。 (由于参数在URI中,因此使用AJAX很可能也会得到相同的问题)。使用AJAX

从服务器接收大量数据很容易。这似乎很难在另一个方向上进行。所以,我正在寻找建议。
<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.



这本身并不是一个JS问题。但是URI大小的限制。

您应该使用POST而不是GET,这样数据就会在HTTP体内而不是URI中转移到


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.


11月3日,7:30 * pm,sheldonlg< sheldonlgwrote:
On Nov 3, 7:30*pm, sheldonlg <sheldonlgwrote:

我可以在这里使用一些帮助。 *我没有太多运气。 *我

已经有一点了,我会很感激建议。


我有一个收集大量数据的表格(A.php)。 *当我发布它时,我

收集数据(在A_process.php中)并使用php和mysql插入/更新到数据库

。 *然后我使用标题重定向回原始页面(A.php)

命令。 *一切正常。
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?


另一个窗口中的可打印版本(B.php)。 *问题是我想要在保持所有数据显示在当前窗口的同时执行此操作。
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.)


>

我尝试创建一个json字符串,以便我只需要
>
I have tried creating a json string so that all I would need is



[snip]


只需创建一个打印介质样式表。

[snip]

Just create a print media style sheet.


slebetman写道:
slebetman wrote:

11月4日上午8:30,sheldonlg< sheldonlgwrote:
On Nov 4, 8:30 am, sheldonlg <sheldonlgwrote:

>< snip>
...结果是该字符串对于服务器的URI来说太长了。 (由于参数在URI中,因此很可能也会使用AJAX获得相同的问题)。使用AJAX
从服务器接收大量数据很容易。它似乎很难朝另一个方向努力。所以,我正在寻找建议。
><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.



这本身并不是一个JS问题。但是URI大小的限制。

您应该使用POST而不是GET,以便数据在HTTP体中而不是URI中传输到

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.



呃,我**请把它作为POST。问题是,我不想离开页面,因此想要通过Javascript / AJAX进行操作。在那些,你

从javascript传递URI中的值到服务器PHP。

帖子用于处理页面以进行数据库工作。

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.


这篇关于传递大量数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆