I'm having issues with a script that I made for use in HTML5. Here is the function
function loadImage(loc,after,para){
var img = new Image();
img.src = loc;
if(typeof(after) != "undefined" && typeof(para) != "undefined"){
img.onloadeddata = after(img,para);
}else if(typeof(after) != "undefined"){
img.onloadeddata = after(img);
}
return img;
}
and here is what is calling it
window.globalFriends[i][2]=loadImage('http://graph.facebook.com/'+window.globalFriends[i][0]+'/picture', function (a){
updateLoaders();
loadingDrawPerson(a);});
What I'm trying to do is send a function as a parameter for it then to be called. It kinda of works but it a weird way. For example; All the images do get loaded but the onloadeddata either fires the function way to early or the function is getting executed before it gets to the loadImage function.
What are your ideas on my malfunctioning script?
Thank-you for reading Paul
typeofis an operator, not a function so there is no need for a grouping operator after it. Use:typeof after