我正在尝试将 3 个 ajax 调用合二为一,但目前我只得到一个。这就是我正在做的事情:
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "/Ws.aspx/One",
dataType: "json",
success: function (result1) {
$('#hpl_one').html(result1.d);
}
}),
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "/Ws.aspx/Two",
dataType: "json",
success: function (result2) {
$('#hpl_two').html(result2.d);
}
}),
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "/Ws.aspx/Three",
dataType: "json",
success: function (result3) {
$('#hpl_three').html(result3.d);
}
}),
现在我希望能够调用这三种方法,但目前我只得到一种:
$(document).ready(function () {
var refreshId = setInterval(function () {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "/Ws.aspx/One",
dataType: "json",
success: function (result1) {
$('#hpl_one').html(result1.d);
}
});
// end calling ajax to count alert
}, 3000);
});
在 HTML 中,我有:
<a id="hpl_one" runat="server">---</a>
<a id="hpl_two" runat="server">---</a>
<a id="hpl_three" runat="server">---</a>
我可以得到hpl_one但我不知道在成功子句中调用hpl_two和hpl_three的语法,非常感谢。