ajax - how to pass checkbox values into .load page using jquery -
i have form checkboxes on want post page (data.php) , want load page inside page using .load function jquery can check checkbox , update query without page have reload. can jquery code i'm new jquery , can't work out code need. appreciated. in advance.
updated:
i have following jquery works, have 2 problems first 1 page im loading data.php has pagination , when links clicked returns no results because page reloading , returning default have 2 groups checkboxes each submit button both same id name ect , top button submits form loads data in page reason bottom submit button loads actual data.php page , don't understand why. if can or point in right direction greatful. thanks
here java script
<script type="text/javascript"> $(document).ready(function() { $("#submit").click(function() { var action = $("#criteria").attr('action'); var form_data = $('#criteria').serialize(); $.ajax({ type: "post", url: action, data: form_data, beforesend:function(){ $('#loader').html('<center><img src="/images/loading-big.gif" alt="loading..." align="absmiddle"/> loading...</center>').fadein('fast');; }, success: function(data){ $('#exercise_list').html(data).fadein('slow'); $("#loader").fadeout('slow'); } }); return false; }); return false; }); </script>
this works. when know better jquery see can find other ways
<div id="target" style="height:100px; width:100px; overflow: hidden"></div> <input type="checkbox" id="chk1"/> <input type="checkbox" id="chk2"/> <script type="text/javascript"> $(document).ready(function() { $('input[type=checkbox]').click(function () { if($(this)[0].checked) { if($(this).attr("id") === "chk1") { $("#target").load("http://www.google.fr"); } else { $("#target").load("www.google.en"); } } }); });
you can use :
$('input[type=checkbox]').on('click', function () {
click method shortcut this
Comments
Post a Comment