aspx ページからデータを取得したい。ただし、充填する場合は静的フィールドでデータを待機します。
Jクエリ:
$.ajax({
url: "Services/JSON/GetMessage.aspx",
type: "GET",
dataType: "json",
success: function (response) { alert(response.Text); },
error: function (x, t, m) {
if (t === "timeout") {
alert("got timeout");
} else {
alert(t);
}
}
})
サービス/JSON/GetMessage.aspx
<%@ Page Language="C#" %>
<%
Response.Clear();
Response.ContentType = "text/json";
int tryCount = 0;
while (1 == 1)
{
if (ClsStaticFields.Messages.Count > 0)
{
foreach(string message in ClsStaticFields.Messages) {
Response.Write("{ Text:'" + message + "' }");
}
}
tryCount ++;
if (tryCount > 29) break; // 1 Minute wait and exit
System.Threading.Thread.Sleep(2000); // 2 Second wait
}
Response.End();
%>
私は興味がありました:
- この待機期間は他のユーザーに影響しますか?
- これは IIS またはページのロックの原因ですか?
- この使用法は CPU に悪影響を及ぼしていますか?