jquery - Use data attribute as post data in .load -
can use data attribute pass variable jquery .load?
<div class="myclass" data-id="1"></div> <div class="myclass" data-id="2"></div> <div class="myclass" data-id="3"></div> <script> $('.myclass').load('my.php',{pk:$(this).data('id')}); </script>
$_post['pk'] ends undefined.
many thanks
try this:
$(".myclass").each(function () { var el = $(this); el.load("my.php", {pk: el.data("id)}); });
Comments
Post a Comment