开发者

problem in get value by ".serialize()"?

开发者 https://www.devze.com 2023-03-29 05:43 出处:网络
i want after click on #value(VALUE) get value input:checkbox with .serialize() ? EXAMPLE: http://jsfiddle.net/tKBJ2/40/

i want after click on #value(VALUE) get value input:checkbox with .serialize() ?

EXAMPLE: http://jsfiddle.net/tKBJ2/40/

$('#value').click(function(e){
  开发者_如何学运维      e.preventDefault();
    alert("this alert only after click on '#value'");
        $('.table_show tr').each(function(){
            if ($(this).prop('checked')) {
                var dataString = $('.table_show').serialize(); // This don't work
                alert(dataString);                
                $(this).parent().parent().fadeOut("slow");
                $.ajax({
                    type: "POST",
                    url: "http://localhost/admin/customer_size/delete",
                    data: dataString,
                    cache: false,
                    success: function(){
                    },
                    error: function(data){
                        alert('Load was performed.');
                    }
                })                
            }
        })
    });


serialize() is used to get query string from the inputs of a form, you should check if the selector select a form element or not.

cf jquery doc : http://api.jquery.com/serialize/

Encapsulate your div table_show in a form, and do serialize on this form:

<form class="myForm">
  <div class="table_show">
    rest of your code
  </div>
</form>

Then in your js :

var dataString = $('.myForm').serialize(); 
0

精彩评论

暂无评论...
验证码 换一张
取 消