データベースから生成されたさまざまなフォームを含むページがあります。各フォームには、データをロードするための下部に div が与えられています。これらには動的 ID があります: tempdiv_1 tempdiv_2 など。
セクションIDを持つ非表示の入力であるthis.input.valのようなものに基づいてdivを更新するためにjqueryを機能させようとしています。
コード:
<script type="text/javascript">
$('#formdataAddForm').live('submit' , function() { // catch the form's submit event
$.ajax({ // create an AJAX call...
data: $(this).serialize(), // get the form data
type: $(this).attr('method'), // GET or POST
url: $(this).attr('action'), // the file to call
success: function(response,data) { // on success..
$.fancybox({
maxWidth : 800,
maxHeight : 200,
fitToView : false,
width : '70%',
height : '70%',
autoSize : false,
closeClick : false,
openEffect : 'none',
closeEffect : 'none',
content : response
});
$('#tempdiv_'+(('input[id="formdataSection"]', form).val())).load('/page/list.php');
}
});
return false; // cancel original event to prevent form submitting
});
</script>
私が仕事に就けないのは、次のようなものです。
$('#tempdiv_'+(('input[id="formdataSection"]', form).val())).load('/page/list.php');
jqueryで動的divを更新するにはどうすればよいですか? フォームはすべて同じ ID を持っているため、フォーム ID を呼び出すことはできません。