Two examples of the use of the a tag in HTML post request are as follows: 1. Use ajax to initiate a POST request The HTML code is as follows: <a href="https://www.jb51.net/" class="a_post">Initiate POST request</a> The JQuery code is as follows: $(".a_post").on("click",function(event){ event.preventDefault(); // Make the method of a invalid, that is, it cannot be adjusted to the URL in href (https://www.cnblogs.com/) $.ajax({ type: "POST", url: "url address", contentType:"application/json", data: JSON.stringify({param1:param1,param2:param2}), //parameter list dataType:"json", success: function(result){ //Operation after request is correct}, error: function(result){ //Operation after request failure} }); }); 2. Use form to initiate POST request <form id="_form" method="post" action="target"> <input type="hidden" name="name" value="value" /> <a onclick="document.getElementById('_form').submit();">Click Submit</a> </form> Summarize This is the end of this article about the two usages of the a tag in html post request. For more relevant content about the a tag in html post request, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! |
<<: Various ways to modify the background image color using CSS3
>>: Introduction to network drivers for Linux devices
Preface: This article refers to jackyzm's blo...
Button is used quite a lot. Here I have sorted ou...
Today, I logged into the server and prepared to m...
1. Leading fuzzy query cannot use index (like ...
<br />This site’s original content, please i...
Table of contents Understanding Prototypes Unders...
Since the problem occurred rather suddenly and th...
This article shares the specific code for Vue to ...
Whether it is a corporate website, a personal blo...
First of all, what is a font icon? On the surface...
1 Introduction Redis is a high-performance NoSQL ...
Menu bar example 1: Copy code The code is as foll...
Ubuntu 15.04 opens MySQL remote port 3306. All th...
How to create a service and auto-start it in Ubun...
After the docker installation is completed on the...