【问题标题】:jquery ajax: submit selected values from a formjquery ajax:从表单提交选定的值
【发布时间】:2013-09-28 17:39:03
【问题描述】:

我有一个这样的表格,我需要提交其中的所有值 class="noDisplay" 除外。将其传递给 控制器并将值更新为 "pd-price"。一切正常,只是我找不到忽略 noDisplay 值来提交表单的方法。

     <div class="cart">
                        <strong>
                            <span class="pd-price">80.407.000đ</span>
                        </strong>

       </div>     


  <form method="post" id="product-details-form" action="xxx">
        <ul>
     <li class="showImg-target noDisplay">
        <input type="radio"  name="product_attribute_46_3_113"> [+3.870.000]
     </li>
     <li class="showImgtarget">
<input type="radio" name="product_attribute_46_4_113">[+1.000.000]</li>

   <li  class="showImgtarget noDisplay">
<input type="radio"  name="product_attribute_46_5_113">[-1.500.000]</li>
    <li  class="showImgtarget noDisplay">
<input type="radio"  name="product_attribute_46_6_113"></li>

                            ..... a lot more 

                                   </ul>
                        </form>


 <script type="text/javascript">
      $(function () {
         updateStatus();
         $('*[name^=product_attribute]').change(function () {
         updateStatus();
         });

       function updateStatus() {
         $.ajax({
                  cache: false,
                  url: '/Catalog/UpdateProductStatus',
                  data: $('#product-details-form').serialize(),
                 type: 'post',
                 success: function (data) {
                 $('.summary-info').html(data.View);
                 $('.pd-price').html(data.Price);
                  $('.powered-icon').replaceWith(data.Pictures);
                        }
                                            });
                                        }
                                    });
                                </script>

【问题讨论】:

标签: asp.net-mvc jquery


【解决方案1】:

你可以使用:not()选择器:

$('#product-details-form li:not(.noDisplay) :input').serialize();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-30
    • 2011-04-23
    • 2012-04-05
    • 1970-01-01
    相关资源
    最近更新 更多