Hi,
I'm making a client side call to a web services but I need to wrap up the functionality that makes the call within another object. The code is below. The code worked fine before I wrapped it in the "ImageViewer" object but now when I try to call the Web Service Method it doesn't recognise the onComplete call back function and says "onComplete" undefined. (See the getImageIDs method). I suspect this is something to do with scope and/or closure but I've been unable to come up with a solution. What is the correct way to do this? Any help will be appreciated.
Type.registerNamespace(
"Raydius");
Raydius.ImageViewer =
function(ImageDivID, ImageListDivID){this.ImageDiv = $get(ImageDivID);this.ImageListDiv = $get(ImageListDivID);this.ImageIDs = [];this.Images = [];}
Raydius.ImageViewer.prototype = {
getImageIDs:function(id){
// Call the WebService
RaydiusWS(id, onComplete);
},
onComplete:
function(results){alert(results);
},
onTimeOut:
function(results){alert(
"Timeout");},
onError:
function(results){alert(
"Error");}
}
Raydius.ImageViewer.registerClass(
'Raydius.ImageViewer');function initImageViewer(){var viewer =new Raydius.ImageViewer("ImageDiv","ImageListDiv");
viewer.getImageIDs(1);
}
See if my example here helps you:
http://forums.asp.net/thread/1574034.aspx
Thanks for the response. There was actually a daft error in my code that was stoppinmg it working both the other post you directed me to was helpful. The userContext param is very useful.
Thanks
Mat
No comments:
Post a Comment