欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

html post請求之a標簽的兩種用法解析

  發(fā)布時間:2020-05-12 15:28:41   作者:麥葉   我要評論
這篇文章主要介紹了html post請求之a標簽的兩種用法,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友參考下吧

html post請求之a標簽的兩種用法舉例,具體內容如下:

1、使用ajax來發(fā)起POST請求

HTML代碼如下:

<a href="http://www.dbjr.com.cn/" class="a_post">發(fā)起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表單來發(fā)起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標簽內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持腳本之家!

相關文章

最新評論