我有这段代码
$.ajax({
type: "POST",
url: "display.aspx/getSchedules",
data: '{"_facilityID":"' + facilityID + '", "_facilityTime":"' + m + '", "_facilityOffset":"' + os + '", "_facilityClock":"' + FacilityClock + '", "_FacilityDisplayPastEvents":"' + FacilityDisplayPastEvents + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
$("#mySchedule").empty().append(data.d);
},
error: function (data) {
toastr.error("Error in getSchedules");
}
});
实际上,我从服务器获取数据然后重新绘制表格。重绘是在webMethod中进行的。就在我使用empty()函数然后为表附加标记,即重绘该表时,该表中突出显示的任何内容似乎都会空白一秒,然后突出显示。
有更好的方法吗? 感谢
任何对webMethod感兴趣的人都是:
[WebMethod]
public static string getSchedules(string _facilityID, DateTime _facilityTime, string _facilityOffset, string _facilityClock, bool _FacilityDisplayPastEvents)
{
if (_facilityID == string.Empty) return string.Empty;
if (_facilityTime == null) return string.Empty;
using (Livein5Entities context = new Livein5Entities()) //USING opens/closes db and manages all that for us
{
int facilityID = Convert.ToInt16(_facilityID);
var facility = context.facilities.Where(u => u.FacilityID == facilityID && u.active == true).FirstOrDefault();
var Facility_location = context.locations.Where(u => u.locationID == facility.locationID).FirstOrDefault();
DataTable Schedules = getAllSchedules(_facilityID, _facilityTime, _facilityOffset, _FacilityDisplayPastEvents);
var ScheduleHTML = "<table class='ScheduleTable'>";
var index = 1;
foreach (DataRow item in Schedules.Rows)
{
DateTime startTime = DateTime.Parse(item[2].ToString());
DateTime endTime = DateTime.Parse(item[3].ToString());
startTime = startTime.AddHours(-8);
endTime = endTime.AddHours(-8);
ScheduleHTML += "<tr ID='FSID_" + index + "' class='ScheduleItem'>";
ScheduleHTML += " <td class='Time'>";
if (_facilityClock == "24") // Check if the user has selected 24 hours or 12 hours.
{
ScheduleHTML += " <div class='StartTime'>" + startTime.ToString("HH:mm") + "</div>";
ScheduleHTML += " <div class='EndTime'>" + endTime.ToString("HH:mm") + "</div>";
}
else
{
ScheduleHTML += " <div class='StartTime'>" + startTime.ToString("h:mm tt") + "</div>";
ScheduleHTML += " <div class='EndTime'>" + endTime.ToString("h:mm tt") + "</div>";
}
ScheduleHTML += " </td> ";
ScheduleHTML += " <td class='Guest'>";
ScheduleHTML += " <div class='GuestName'>" + item[4].ToString() + "</div>";
ScheduleHTML += " <div class='Topic'>" + item[5].ToString() + "</div>";
ScheduleHTML += " </td>";
ScheduleHTML += " <td class='EventDetails'>";
ScheduleHTML += " <div class='EventName'>" + item[6].ToString() + "</div>";
ScheduleHTML += " <div class='Host'>" + item[7].ToString() + "</div>";
ScheduleHTML += " </td>";
ScheduleHTML += "</tr>";
index++; // Increment The ID Number - Index
}
ScheduleHTML += "</table>";
return ScheduleHTML;
}