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
Table of contents What is cgroup Composition of c...
I was watching Tik Tok some time ago and thought ...
MySQL Introduction to MySQL MySQL was originally ...
1. Go to Vim's official website to download t...
Preface This article will explain how Vue compone...
Please open the test page in a mainstream browser...
Preface 1. Benchmarking is a type of performance ...
Table of contents Preface optimization SSR Import...
HTML Paragraph Paragraphs are defined by the <...
Table of contents 1. Example scenario 1.1. Set th...
Table of contents 1. Use JavaScript to parse the ...
How to save and exit after editing a file in Linu...
1. Use Docker Compose to configure startup If you...
This article deploys Jenkins+Maven+SVN+Tomcat thr...
Table of contents 1. JavaScript is single-threade...