Jquery - Send only some value from a form

江枫思渺然 提交于 2019-12-23 23:19:27

问题


using the checkTL() function, i need to send to the server (for example) only the input value into div with class "sideon". So, in the example, i need to get (server side) only the value of inputside0 and inputside3. How is possible this? cheers


回答1:


How about using AJAX?

<form method="POST" action="./index.php?general=example3" name="addtl">
    ...
</form>

and then:

$(function() {
    $('form[name=addtl]').submit(function() {
        var dataToPost = $(this).find('.sideon :input').serialize();
        $.post(this.action, dataToPost, function(result) {
            alert('success');    
        });
        return false;
    });
});

Of course putting input fields whose values shouldn't be submitted to the server into a form is doubtful. Maybe you should rethink the way you organize the forms.




回答2:


two ways:

  1. make them into lots of seperate forms.
  2. do return false on the form submit in jquery and use $(".sideon").find('input').val(); to post an ajax query


来源:https://stackoverflow.com/questions/3746478/jquery-send-only-some-value-from-a-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!