I have an AJAX application that calls Apache
Tomcat.
I have one problem that I cannot solve and need help on.
One of the application's jobs is to call the
servlet with a
message to get an image name. Once the image name is retrieved, it is loaded into a snippet of HTML as follows:
<img id='myimage' src='http://www. ... /images/nameThatWasFound.jpg' />
The
servlet then returns the HTML snippet, and the
application places it in an element's id as follows:
document.getElementById("myimage").innerHTML = theHTMLReturned
This
works fine for a desktop browser such as Chrome and IE, but when I call it from a
mobile phone,
the image
does not display. If I tap the phone's screen however, then the image will appear.
I have tried to do the following to get the image to refresh, but the element id "myimage" is null, and it cannot be accessed for some reason I do not understand:
var el = document.getElementById('myimage');
el.setAttribute('src', el.getAttribute('src') + '?m='+Math.random());
I cannot understand why the element 'myimage' is null first of all, and secondly why the image will not load for display on the phone.
Any ideas? Doesn't work on a cell phone (Android).