我正在网站上使用一些代码,我正在尝试按成员 ID 对结果进行排序(我在下面的代码中留下了注释)它似乎没有对结果的顺序进行排序,所以我猜我一定做错了什么。有谁知道问题是什么,也许我可以如何将显示的结果数量限制在 10 左右?
var httpRequestObject = $.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "/Wcf/Search.svc/TestSearch",
dataType: "json",
success: function (response) {
if (response != null && response.d != null) {
var data = response.d;
if (data.ServiceOperationOutcome == 10) {
var profileList = data.MemberList;
if (profileList != null && profileList.length > 0) {
for (var i = 0; i < profileList.length; i++) {
var profile = profileList[i];
// sort var
var memberId = (profile.MemberId);
if (profile != null) {
var clonedTemplate = $('.profile-slider #profile').clone();
$(clonedTemplate).removeAttr('style').removeAttr('id');
$(clonedTemplate).find('img').attr("src", profile.ThumbnailUrl).attr("alt", profile.Nickname).wrap('<a></a>');
$(clonedTemplate).appendTo('.profile-slider');
// sort
$(memberId).sort();
}
}
}
}
else {
alert("Error code " + String(data.ServiceOperationOutcome));
}
}
else {
alert("Null data");
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});