Talking about Web Data Interaction (1)

zhaozj2021-02-16  100

The C / S mode and B / S have a bit a bit thereafter, and the B / S mode needs to consider how data is submitted from the client to the server, and the data returns to the client, these is B / S The model is unique, before last year, develop B / S mode procedures, I use form to interact data, when I see XML, I found XML is a good winter winter, there are many advantages, there is certain of course can't Exclusive, I want to achieve the network to turn the network over the Internet. Hey, a piece of brick came up. Oh, nonsense, let's enter the topic below.

The B / S mode is divided into server-side and clients, client accepts user requests, clients to apply services to the application service, apply services from database services, calculate data, and submit the results to the client, The client is presented to the user. In this way, we will see the data from the customer to the server, and then return to the client, and the result is displayed by the client software (such as IE).

(As an example of ASP, other languages ​​are like.)

1. FORM way

The form method is the most basic way to submit data to the server.

TEST.ASP file code:

<% @ Language = VBScript%>

<%

Response.expires = -1

Response.Charset = "UTF-8"

Session.codepage = "65001"

%>

>

<%

DIM INTNUMBER

DIM STRNAME

IF ISEMPTY (Request ("name")).

Strname = ""

Else

Strname = Request ("name")

END IF

IF iSempty (Request ("Number")).

INTNUMBER = 0

Else

INTNUMBER = Request ("Number")

END IF

Response.write ("
")

Response.write ("You Input Name IS:" & STRNAME)

Response.write ("
")

Response.write ("Hidden Number Value IS:" & INTNumber)

%>

This code completes input data from the client, and then submitted to the server side via the Form, and the server page is sent to the client to the client display. Let's explain this code:

This code is a submission domain that is submitted to the server side when this Form is submitted. The action is the page submitted to the page, that is, the page receiving the FORM data, here is the page itself, of course, it can also be other pages.

Method is a way of submitting

>

This code is an input box,

This code is hidden Value, which is not displayed on the page to save some data.

When the button is pressed, the Form is to server data. Server-end script

IF ISEMPTY (Request ("name")).

Strname = ""

Else

Strname = Request ("name")

END IF

Request ("name") acquires the value of Name in the submitted Form.

2. URL method

The specific approach is to pass the data to the server through the URL address bar.

Still named Test.asp

<% @ Language = VBScript%>

<%

Response.expires = -1

Response.Charset = "UTF-8"

Session.codepage = "65001"

%>

Go

<%

DIM INTNUMBER

DIM STRNAME

IF ISEMPTY (Request ("name")).

Strname = ""

Else

Strname = Request ("name")

END IF

IF iSempty (Request ("Number")).

INTNUMBER = 0

Else

INTNUMBER = Request ("Number")

END IF

Response.write ("
")

Response.write ("You Input Name IS:" & STRNAME)

Response.write ("
")

Response.write ("Hidden Number Value IS:" & INTNumber)

%>

Go This super connection point ./test.asp, it is itself, of course, can you point to other files, indicating the parameters that started.

Parameter Name assignment YourName, pass & connection between different parameters

Through the comparison of the drawings and the above figure, we can find that the data passed through the URL will be displayed in the URL of the browser so that the user can see how we submit data, of course, can also directly modify the value inside the URL to pass Parameter.

Note: Transfer parameters through the URL, the URL needs to be encoded, otherwise it may be garbled.

转载请注明原文地址:https://www.9cbs.com/read-14639.html

New Post(0)