gpt4 book ai didi

c# - ajax调用jquery后如何防止页面重新加载

转载 作者:太空宇宙 更新时间:2023-11-03 12:50:54 24 4
gpt4 key购买 nike

我想在 ajax 调用后停止页面重新加载。基本上我想显示 div 并填充具有一些数据的局部 View 。 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 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 上的 OnClick 事件

<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);
}

enter image description here

最佳答案

请使用 firebug 检查您的控制台。也许它正在从您的脚本中调用您的某些 Controller 方法,也许它可以帮助您解决问题。有什么事请告诉我。请查看此图片。这就是您在 firebug 中看到的 ajax 调用的工作方式。

enter image description here

关于c# - ajax调用jquery后如何防止页面重新加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35601437/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com