html post請求之a標籤的兩種用法舉例,具體內容如下:
1、使用ajax來發起POST請求HTML代碼如下:
<a href=https://www.VeVb.com/ class=a_post>發起POST請求</a>
JQuery代碼如下:
$(.a_post).on(click,function(event){ event.preventDefault();//使a自帶的方法失效,即無法調整到href中的URL(https://www.cnblogs.com/) $.ajax({ type: POST, url: url地址, contentType:application/json, data: JSON.stringify({param1:param1,param2:param2}),//參數列表dataType:json, success: function(result){ //請求正確之後的操作}, error: function(result){ //請求失敗之後的操作} });}); 2、使用form表單來發起POST請求<form id=_form method=post action=target> <input type=hidden name=name value=value /> <a onclick=document.getElementById('_form').submit();>點擊提交</a></form>總結到此這篇關於html post請求之a標籤的兩種用法解析的文章就介紹到這了,更多相關html post請求a標籤內容請搜索武林網以前的文章或繼續瀏覽下面的相關文章,希望大家以後多多支持武林網!