javascript - XML : Set default.jpg if image not found -


i have for-loop, puts images json file (which taken database) xml code.

- '<lockup><img src="' + pictureurl + result.response[i].a_picture + '"  width="1280" height="980"/></lockup>' - 

now problem is, every image urls set in database, : not every image urls still exist, since not updated.

what want is, setting custom default.jpg xml instead of having blank picture don't exist.

i tried every code snippet on stackoverflow , searched every answers, , online aswell, cant work.

i still think have work "onerror" don't know how.

- '<lockup><img src="' + pictureurl + result.response[i].a_picture + '"  onerror="if (this.src != '"http://myip/content_images/default.jpg"') this.src = '"http://myip/content_images/default.jpg"';" width="1280" height="980"/></lockup>'; - 

do have make if-clause inside for-loop detects non-existing files , replacing them?


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -

Python Tornado package error when running server -