使用 AJAX 只提交一个表单

在选择标签中添加一个属性 id="tour_category" 并尝试


$(document).ready( function(){

    var a = new Array();

    $("#tour_category").children("option").each(function(x){

        test = false;

        b = a[x] = $(this).val();

        for (i=0;i<a.length-1;i++){

            if (b ==a[i]) {

               test =true;

            }

        }

        if (test) {

           $(this).remove();

        }

    })

});


互换的青春
浏览 151回答 1
1回答

MYYA

您必须指定要提交的表单试试这个,$('.submit-like').click(function(){&nbsp; &nbsp; &nbsp;$(this).parent().submit()})$('like-form-js').submit(function(e){&nbsp; &nbsp; e.preventDefault();&nbsp; &nbsp; $.ajax({&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url: 'some-url',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type: 'post',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dataType: 'json',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data: $(this).serialize(),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; success: function(data) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.log('success');&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; });})
打开App,查看更多内容
随时随地看视频慕课网APP