I have a page that contains a div for a partial view that is being returned via an ajax request.
我有一个页面,其中包含通过ajax请求返回的部分视图的div。
$.ajax({
url: 'CompleteSessions',
success: function (data) {
var selector = $('#complete-session-section');
if (data.length > 0) {
selector.html(data);
}
else {
selector.append($(document.createElement('option')).html('No assessments'));
}
}
});
The partial view itself has a model and constructs a combobox based on the number of returned sessions.
分部视图本身有一个模型,并根据返回的会话数量构造一个组合框。
@using SmartQWeb.Models.Entities
@using SmartQWeb.Runtime;
@model IEnumerable<Session>
<span class="dropdown">
<select style="width: 75%" id = "complete-session-selector">
<option id="-1">Select a Session</option>
@foreach (Session session in Model.OrderByDescending(date=>date.StartTime))
{
if (session.Assessment != null)
{
<option id="@session.AssessmentId" value="@session.Id" title="Administered by: @session.User.Name" data-assessmentId="@session.AssessmentId">@session.Participant.AliasLookup.AliasId - @session.StartTime </option>
}
}
</select>
</span>
The problem is that, only for IE, the dropdown does not get properly updated when the page is first loaded. I have to hit F5 (sometimes control F5) to refresh and see the new entries in the combobox. This is not a problem for Chrome or Firefox.
问题是,仅对IE而言,当页面首次加载时,下拉菜单不会得到正确的更新。我必须按F5(有时控制F5)刷新并查看combobox中的新条目。这对Chrome和Firefox来说不是问题。
1 个解决方案
#1
3
The default 'type' argument for jQuery ajax requests is 'GET' which IE will cache. You can disable caching in your ajax request or switch to a 'POST' to prevent this --
jQuery ajax请求的默认“类型”参数是“GET”,IE会缓存它。您可以在ajax请求中禁用缓存,或者切换到“POST”以防止这种情况发生。
$.ajax({
...
cache: false
});
#1
3
The default 'type' argument for jQuery ajax requests is 'GET' which IE will cache. You can disable caching in your ajax request or switch to a 'POST' to prevent this --
jQuery ajax请求的默认“类型”参数是“GET”,IE会缓存它。您可以在ajax请求中禁用缓存,或者切换到“POST”以防止这种情况发生。
$.ajax({
...
cache: false
});