How Make AJAX REQUEST with clicking in the link not submit button

前端 未结 4 1226
悲&欢浪女
悲&欢浪女 2021-01-19 06:27

How could I make an AJAX REQUEST by clicking on a link instead of a submit button? I want once the link is clicked to POST data from input fields

4条回答
  •  误落风尘
    2021-01-19 07:03

    $('selector').click(function(e){
      e.preventDefault();
      $.ajax({
           url: "",
           type: "POST",//type of posting the data
           data: ,
           success: function (data) {
             //what to do in success
           },
           error: function(xhr, ajaxOptions, thrownError){
              //what to do in error
           },
           timeout : 15000//timeout of the ajax call
      });
    
    });
    

提交回复
热议问题