ページに複数のセクションがあり、それぞれに独自の ID があります。ページがロードされたら、コントローラーからそれぞれの実際のビューをロードし、以下のサンプル コードに従って、これをそのセクションに配置しようとしています。
ただし、ページを更新するたびに、コンテンツが届く場合と届かない場合があります。そのため、すべてのコンテンツがある場合もあれば、2 つまたは 3 つしかない場合もあれば、すべてのコンテンツがある場合もあります。何が間違っていますか? コントローラーから返されるデータは、ほんの少しの html です。
インデックス.cshtml
<table class="table1">
<tr>
<td colspan="2"><section id="id1" class="ctrl1 mainPanel"></section></td>
<td colspan="2"><section id="id2" class="ctrl2 mainPanel"></section></td>
</tr>
<tr>
<td colspan="2"><section id="id3" class="ctrl3 mainPanel"></section></td>
<td><section id="id4" class="ctrl4 mainPanel"></section></td>
<td><section id="id5" class="ctrl5 mainPanel"></section></td>
</tr>
</table>
@section scripts {
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
<script>
$(document).ready(function () {
$("#id1").load("/MyController/GetData1");
$("#id2").load("/MyController/GetData2");
$("#id3").load("/MyController/GetData3");
$("#id4").load("/MyController/GetData4");
});
</script>
MyController から:
public ActionResult GetData1()
{
String s = "<b>Section 1 header</b><br><br>";
s += "<ul><li>3 appointments</li><li>2 tasks</li></ul>";
return Content(s);
}
等...