I am trying to post image to user wall using javascript FB.api. Image is generated from a java servlet dynamically, but due to asynchronous behavior before the image is generated it passes control below the block to post image to Facebook part. I want either [*]how can I make fb.api post to Facebook call from servlet?[*]how to deal with this behavior so that control will not passes below before image generation?note servlet is working file and generating image .\[code\]var imgURL="http://xxx.xxx.xxx.xxx:8084/myapps/app1?monthly="+monthly+"&recent="+recent+"&likes="+likes;//var imgURL="http://xxx.2xx.xx6.1x8:8084/WebApplication6/image";alert('image');//var imgURL="https://graph.facebook.com/100000329585395/picture";var img = document.createElement('img');img.src =http://stackoverflow.com/questions/13820658/imgURL;document.body.appendChild(img);FB.api('/me/photos', 'post', {message:'image',url:imgURL }, function(response){ alert('here');if (!response || response.error) { alert('Error occured'+response.error);} else { var postId = response.id; alert(postId);}});\[/code\]