I use AJAX page methods, but I can not pass the necessary parameters:
function getFavStatus() {
for (i = 0; i < favs.length; i++) {
PageMethods.isFavorite(favs[i].alt,setFavImg(favs[i]));
}
}
function setFavImg(fav, response) {
fav.src = response;
}
A problem that I cannot understand is how to use the "answer" from PageMethods, and pass the DOM object to the callback function.
I also tried to do something like this:
function getFavStatus() {
for (i = 0; i < favs.length; i++) {
PageMethods.isFavorite(favs[i].alt, function (response) {
favs[i].src = response;});
);
}
}
In this case, the answer works correctly, but ialways > favs.length, because it has already repeated the loop ...
Change . My signature is PageMethods.isFavorite:
[System.Web.Services.WebMethod]
public static string isFavorite ( string p_id )
Can someone point me in the right direction?
Thank!
source
share