Home Web Front-end JS Tutorial Detailed explanation of the four forms of parameter passing_Basic knowledge

Detailed explanation of the four forms of parameter passing_Basic knowledge

May 16, 2016 pm 03:49 PM
Parameter passing

This article is summarized in daily work. The four forms of parameter transfer are shown below.

When to use GET, search, delete,

When to use POST, add, change (Special: use POST to log in, because the username and password cannot be displayed on the URL)

4 ways to get parameters

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
 <title></title> 
 <script type="text/javascript"> 
  function Go() { 
   window.location.href="localhost:21811/Handler1.ashx?id=1&name='abc'" 
  } 
 </script> 
</head> 
<body> 
Copy after login


<!--//Several forms of parameter passing-->

<!--The first method: add parameters directly after the URL:-->

Copy code The code is as follows:

localhost:21811/Handler1.ashx?id=1&name="abc"

<!--Second: Use hyperlink method to pass parameters: When clicking the hyperlink, it will first jump to the localhost:21811/Handler1.ashx page, and then pass the two parameters id and name to the past - ->

<a href="localhost:21811/Handler1.ashx?id=1&name='abc'">Hyperlink transfer parameters</a></body>
<!--Third method: Passed through js method: The user clicks this button button, triggers the onClick event, executes the Go() method, jumps to the localhost:21811/Handler1.ashx page, and passes both the id and name at the same time Parameters passed-->
<input type="button" onclick="Go()" value="Pass parameters through js method" />
<!--The fourth method: passing through the form-->
 

 &lt;form action="Handler1.ashx" method="get"&gt;&lt;!--注意action里面的连接不能带参数的--&gt;&gt; 
  &lt;input type="text" name="id" value="3" /&gt; 
  &lt;input type="text" name="name" value="abc" /&gt; 
  &lt;input type="submit" value="通过传递参数" /&gt; 
 &lt;/form&gt; 
&lt;/body&gt; 
&lt;/html&gt; 
Copy after login

Through the introduction of the above code, I believe everyone will like it.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Best practices for optimizing Golang function parameter passing performance Best practices for optimizing Golang function parameter passing performance Apr 13, 2024 am 11:15 AM

Best practices for optimizing Golang function parameter passing performance

Detailed explanation of C++ function parameters: Performance optimization of parameter passing in parallel programming Detailed explanation of C++ function parameters: Performance optimization of parameter passing in parallel programming Apr 27, 2024 pm 02:09 PM

Detailed explanation of C++ function parameters: Performance optimization of parameter passing in parallel programming

Research on parameter passing methods in Go language Research on parameter passing methods in Go language Apr 03, 2024 pm 02:48 PM

Research on parameter passing methods in Go language

C++ function pointer parameter passing mechanism C++ function pointer parameter passing mechanism Apr 19, 2024 pm 02:06 PM

C++ function pointer parameter passing mechanism

golang function map passed as parameter golang function map passed as parameter Apr 22, 2024 am 11:42 AM

golang function map passed as parameter

What is the parameter passing method for PHP functions? What is the parameter passing method for PHP functions? Apr 10, 2024 am 11:06 AM

What is the parameter passing method for PHP functions?

The relationship between C++ function parameter passing methods and variable parameter functions The relationship between C++ function parameter passing methods and variable parameter functions Apr 13, 2024 am 08:30 AM

The relationship between C++ function parameter passing methods and variable parameter functions

How to write a function with output parameters (called by reference) in Python? How to write a function with output parameters (called by reference) in Python? Sep 02, 2023 pm 04:21 PM

How to write a function with output parameters (called by reference) in Python?

See all articles