我有这个模态并且在SaveChangesofCollectorID id
中 <div class="modal fade" id="mymodal" role="dialog" >
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<input id="ToDate" name="ToDate" readonly="readonly"/>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" style="width:40px;">no</button>
<button id="SaveChangesofCollectorID" data-dismiss="modal" type="button" class="btn btn-default" style="width:40px;">yes</button>
</div>
</div>
</div>
它没有发动它的事件
,或者只是发出第一个警报,
甚至我删除了data-dismiss =&#34; modal&#34;
这是我的实验
$("#SaveChangesofCollectorID").click(function () {
alert("inserted here");
$.ajax({
type: "POST",
url: "UnloadingCalendar.aspx/SaveChangesofCollector",
data: JSON.stringify({ CollectorID: CollectorID, FromDate: startday, ToDate: EndDate, DaysCount: countdays }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
OpenConfirmationModal();
},
error: function (msg) {
alert(msg.d);
},
complete: function () {
}
});
});
</div>
答案 0 :(得分:0)
这是一个工作小提琴:https://jsfiddle.net/code4pi/6rvd073L/
您的代码没有任何问题,如果您要将其内联(或者更好,将js移动到自己的文件中),您只需将js包装在脚本标记中:
<script>
$("#SaveChangesofCollectorID").click(function () {
alert("inserted here");
$.ajax({
type: "POST",
url: "UnloadingCalendar.aspx/SaveChangesofCollector",
data: JSON.stringify({ CollectorID: CollectorID, FromDate: startday, ToDate: EndDate, DaysCount: countdays }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
OpenConfirmationModal();
},
error: function (msg) {
alert(msg.d);
},
complete: function () {
}
});
});
</script>