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

前端 未结 4 1192
悲&欢浪女
悲&欢浪女 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:05

    With jQuery

    $('#link-selector').on('click', function(event) {
        event.preventDefault();
        $.post('url', {$('form selector').serialize()}, function(json) {
            // proccess results
        }, 'json');
    });
    

提交回复
热议问题