在单击按钮后,必选属性不起作用。
我有三个按钮btn-insert
,btn-update
btn-insertvideo
,但是按btn-insert
后,它不生效
我的代码:
<form method="POST" id="topic_form" class="form-horizontal well">
<div class="col-sm-12">
<select id="mainCatItem" name="mainCatItem" class="form-control" required>
<option value="">Select Category</option>}
option
<?php foreach($fetchcat as $fetchcategory): ?>
<option value="<?php echo $fetchcategory->main_category_id; ?>"><?php echo $fetchcategory->main_category_name; ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group row mb-0">
<div class="col-sm-6">
<Button type="submit" id="btn-insert" value="Submit" class="btn btn-primary">Add</Button>
<button type="submit" id="btn-update" value="Submit" class="btn btn-primary">Update</button>
</div>
</div>
<input id="btn-insertvideo" type="button" value="Submit" onclick="save()" class="btn btn-primary">
</form>
<script>
$('#btn-insert').click(function(e){
e.preventDefault();
$.ajax({
url: "<?php echo base_url();?>admin_controller/WebsiteContentController/createtopic",
type: "POST",
data: $('#topic_form').serialize(),
dataType:'text',
success: function(response)
{
alert(response);
}
});
});
</script>
点击btn-insert
后,我想显示要求消息
如果未选择dopdown,我想在btn-insert
单击后停止该ajax