현재 사용자가 하나 이상의 항목을 한 번에 추가 할 수있는 곳에서 작업중인 프로젝트의 새로운 기능에 대해 작업하고 있습니다. 단계는 다음과 같습니다.Div는 ajax 호출에서 PartialView를 새로로드하지 않습니다.
- 연간 보고서 추가 버튼을 클릭합니다.
- Telerik Modal Window가 상태 드롭 다운 목록과 함께 나타납니다.
- 실제 상태를 선택하면 날짜 선택 도구가 나타납니다 (Telerik도 해당).
- 대신 Projected를 선택하면 시작 날짜에 날짜 선택 도구가 나타나고 최종 연도 선택 항목 (Projected는 여러 해를 실행할 수 있음)에 대한 다른 드롭 다운이 나타납니다.
- 선택한 날짜 필드에 날짜 필드가 채워지면 추가 버튼을 클릭하십시오.
- Add를 클릭하면 서버에 접근하는 ajax 메서드가 실행되고 새 연간 보고서 목록이 만들어져 Session 개체로 전송됩니다. 모든 것이 성공하면 다시 되돌아옵니다.
- 성공하면 성공했다는 텍스트를 표시 한 다음 창을 닫고 연례 보고서 목록이 포함 된 div를 새 것으로 업데이트하십시오.
그러나 지금까지 모든 것이 작동하지만 문제가 있습니다. 마찬가지로 여러 번 실행하면 모든 연례 보고서 버그를 포함하고있는 div가 처음으로 새로 고침하거나 이전 데이터를 사용하지 않습니다. 새로 고침되지 않습니다. 나는 내 아약스 호출에 대한 캐싱을 해제하고, 경고를 제거하고, setTimeout 인스턴스를 제거하고, div를 제거하고 다시 추가했다. 그 중 아무 것도 div를 새로 고치는 것처럼 보이지 않는다.
그러나 IE Developer Tools를 켜면 작동합니다. 나는 캐싱을 사용하는 것으로 IE가 악명 높다고 읽는데, 때로는 좋지만이 경우에는 그렇지 않다.
캐싱을 끄고 div를 다시로드하도록 할 방법이 있습니까?
다음은 내 코드입니다.
AddARPartialView.cshtml :
$(document).ready(function() {
$("#btnAdd").click(function (e) {
//Stop system from proceeding to server immediately
e.preventDefault();
//Used for checking Completion
var success = false;
//Show spinner while system processes page
//ShowProgress();
//Check to see if there was any validation errors
ShowValidationErrors();
//There was an error, so do nothing
if (hasError) {
//hideprogessbar();
return false;
}
//Save Message
$.ajax({
type: "POST",
cache: "false",
url: "/PM/AddARPartialView",
dataType: "json",
data: $('form').serialize(),
success: function (result) {
if (result.success) {
//Mark Success as true
success = true;
//Hide the Progress bar and show the success message
//hideprogessbar();
}
else {
//Mark Success as false
success = false;
//hideprogessbar();
var DetailError = 'Error while creating new Annual Reports. Please contact administrator with below details.'
+ '\n' + '\n' + result.Error;
$("#lblError").show();
$("#lblError").text(DetailError);
}
},
error: function (xhtr, e, e2) {
alert(e + '\n' + xhtr.responseText, 'error', '');
},
complete: function() {
if (success)
{
CloseARModal();
UpdateAnnualReports();
}
}
});
});
});
정기 페이지 :
function CloseARModal() {
var arWindow = $("#AnnualReport").data("tWindow");
arWindow.close();
}
function UpdateAnnualReports() {
//Show spinner while system processes page
//ShowProgress();
$.ajax({
type: "GET",
cache: "false",
url: "/PM/ARPartialView",
success: function (result) {
$("#divARe").html(result);
},
error: function (xhtr, e, e2) {
if (xhtr.status === 401)
alert("Session Timeout or Unauthorized to access this webpage");
else
alert(e + '\n' + xhtr.responseText);
}
});
//hideprogessbar();
//alert("New Annual Report(s) added successfully!");
}