Two usages of the a tag in html post request are given, the specific content is as follows:
1. Use ajax to initiate a POST requestThe HTML code is as follows:
<a href=https://www.VeVb.com/ class=a_post>Step POST request</a>
The JQuery code is as follows:
$(.a_post).on(click,function(event){ event.preventDefault();//Invalidate the method provided by a, that is, it cannot be adjusted to the URL in the 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 the request is correct}, error: function(result){ //Operation after the request is failed} });}); 2. Use form form to initiate a POST request <form id=_form method=post action=target> <input type=hidden name=name value=value /> <a onclick=document.getElementById('_form').submit();>Click to submit</a></form> SummarizeThis is the end of this article about the two usages of the a tag of html post request. For more related contents of html post request a tag, please search for previous articles of Wulin.com or continue to browse the related articles below. I hope everyone will support Wulin.com in the future!