我想在ajax调用后停止页面重新加载。基本上我想显示div并填充具有一些数据的局部视图。在ajax调用之后,我的页面开始刷新,如图所示。我的代码是
function GetAllSlot(doctorid, schid, dayid) {
$("#doctorsScheduler").html('');
$.ajax({
url: '/Appointment/GetAllSlotsForDoc',
type: 'GET',
data: { doctorId: doctorid, schid: schid, dayID: dayid },
async : true,
success: function (innerData) {
$("#doctorsScheduler").slideToggle("slow", function () {
$("#doctorsScheduler").html(innerData);
});
}
});
}
我的div
<div class="col-lg-12 col-sm-12 col-md-12">
<div class="row">
<div class="card-box" style="display: none;" id="doctorsScheduler">
</div>
</div>
</div>
在Div上点击事件
<div class="col-sm-2" onclick="GetAllSlot(@item.ID,@items.ID,@items.DayID)">
<a href="#">
<div class="card-box bg-success">
<div class="media">
<div class="media-left">
<img class="media-object" src="~/Content/Hosiptal-icon/DoctorsApp.png" alt="">
</div>
<div class="media-right">
<h4 class="media-heading" style="text-align: left; width: 500%; color: black">@item.DoctorName</h4>
</div>
</div>
</div>
</a>
</div>
服务器端代码:
public ActionResult GetAllSlotsForDoc(long doctorId,long schid, long dayID)
{
var roomno = (from p in db.SchedulerSettings where p.FKDoctorID == doctorId && p.DayID == dayID select p.RoonNo).
Single();
ViewBag.DayOfWeek = (DayOfWeek)dayID;
ViewBag.RoomNo = roomno;
var getslotsfordoct = new GetSlotsForDoctor();
var appointmentlist = getslotsfordoct.GetSlotsforDoctor(doctorId,schid,dayID);
return PartialView("~/Views/PartialViews/AppointmentDeskDashBoard/_GetAppointmentSlotsPartailView.cshtml", appointmentlist);
}