我通过ajax向数据库提交一些值,我想在ajax调用后重新加载并打开一个特定的accordion div。
这是我正在尝试的,它不起作用=
function submit(id) {
var submitID = '#' + id + 'submit';
var divId = '#' + id + 'myDiv';
$.ajax({
'url' : base_url + controller + '/add_val',
'type' : 'POST',
data : { var: $(submitID).val()
},
'success': function (data) {
$("#divId").html(data);
$("#divId").load(window.location + divId);
$("#accordion").accordion("option", "active", $("#accordion div").index(divId));
}
});
}
HTML代码在这里:
<div id="accordion">
<?php foreach ($divKey as $val): ?>
<h3><?php echo $val->name; ?></h3>
<div id="<?php echo $val->id . "myDiv"; ?>">
<select class="s2_select" id="<?php echo $val->id . "submit"; ?>" name="">
<option>value 1</option>
<option>value 2</option>
<option>value 3</option>
</select>
<input type="button" class="btn btn-default" value="Add" onClick="submit(<?php echo $val->id; ?>)">
<ul>
<li>....</li>
</ul>
</div>
<?php endforeach; ?>
</div>