开发者

Submit Post Data Without a Form in ASP Classic/VBScript

开发者 https://www.devze.com 2023-03-19 04:32 出处:网络
I\'m using ASP classic and I\'d like to submit post data without actually having a form. Here\'s the scenario. The user fills out a comment box in a form on Page1. The form uses Post to submit the da

I'm using ASP classic and I'd like to submit post data without actually having a form.

Here's the scenario. The user fills out a comment box in a form on Page1. The form uses Post to submit the data for Page2. Page2 processes the incoming data and redirects back to Page1 using the Response.Redirect method. If the user has filled out something incorrectly I need to post this data back to Page1 so the user does not lose what he has typed. Page2 is not intended to actually display any HTML at any time. It's merely used as a comment processing page 开发者_运维百科and always redirects no matter what. Is there a better or preferred way of doing this?

jQuery has the .post method which allows you to do what I'm asking for. However, I'm really not sure how I'd integrate this with my ASP page. I supposed I'd actually have to display an HTML page momentarily and then have jQuery handle the redirect after the page is loaded. This also means that I'd have a form with values which jQuery would extract. I think this would probably be an OK work-around but I'd prefer a more "native" solution if one exists.


Depending on your system Server.Transfer() could be a solution. So when you do a Server.Tranfer() from Page2 to Page1 all your data is there again.

From the docs:

The Transfer method sends (transfers) all the state information (all application/session variables and all items in the request collections) created in one ASP file to a second ASP file.

When the second ASP page completes its tasks, it will NOT return to the first ASP page (like the Execute method).

Note: The Transfer method is an efficient alternate for the Response.Redirect. A redirect forces the Web server to handle an extra request while the Server.Transfer method transfers execution to a different ASP page on the server, and avoids the extra round trip.

0

精彩评论

暂无评论...
验证码 换一张
取 消