javascript - Array of images is not showing proper without alert box on cavas with x , y coordinates -


i have got image names in loop xml file using ajax , showing on html canvas x, y coordinates. images not show proper without alert box. means if put alert box showing fine if remove alert box code images showing on last x, y coordinates.
html code -

<canvas id="mycanvas"   style="border:1px solid #000000;"></canvas> 

my javascript code -

var canvas = document.getelementbyid("mycanvas"), var ctx = canvas.getcontext("2d");  (iimg=0;iimg<ximg.length;iimg++) {    // here getting below values in each variable     var callimgdata=ximg[iimg].childnodes[0].nodevalue;    var callout_imagex=xx[iimg].childnodes[0].nodevalue;    var callout_imagey=xy[iimg].childnodes[0].nodevalue;    var callout_imageheight=xh[iimg].childnodes[0].nodevalue;    var callout_imagewidth=xw[iimg].childnodes[0].nodevalue;  (function(){    var letterimg = new image();    letterimg.onload = function() {    ctx.drawimage(letterimg, callout_imagex, callout_imagey, callout_imagewidth, callout_imageheight);    }    letterimg.src = sitepath+"atom/chapter1/book/"+callimgdata; })(iimg);  // if remove below alert images showing on last x, y coordinates fine when keep alert here.  alert(callimgdata+" ,"+ callout_imagex +" ,"+ callout_imagey+" ,"+ callout_imagewidth+" ,"+ callout_imageheight); 


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -