×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Regular Contributor
    Join Date
    Mar 2005
    Location
    Hamburg, Germany
    Posts
    285

    Dynamic image problem, src not recognized

    Hello experts,

    I have a list-detail-type of Webapp, there is a list of objects, when the user selects one, another page is displayed, the details for the items are displayed. So the detail page needs to be filled in dynamically.

    It works for text, I can get html-elements by id and call innerText('mycontent') on them. Now I want also an image, where I set the src dynamically.

    First try: get a predefined image, and call setAttribute('src', 'url')
    This is not working. Maybe because it is not alloewed to set "client side style properties".

    Second try:
    create the image tag as string <image src=I change src=""> and add it to the wrapping div with innerHTML(). This adds an image, but the url is not recognized.
    In the debugger I see either the src attribut with spaces inserted after slashes
    "http://mydomain/path" -> "http:/ / mydomain/ path",
    or in the properties debugger dialog I see an empty src property.

    So how can I set display an image with a dynamic created src url?

    Regards

    Karsten Meier

  2. #2
    Registered User
    Join Date
    Aug 2011
    Posts
    26

    Re: Dynamic image problem, src not recognized

    Quote Originally Posted by internetlabor View Post
    First try: get a predefined image, and call setAttribute('src', 'url')
    Have you tried setting the "src"-variable of the image to your new url?
    Eg document.getElementById("myimg").src=newSrc

    I didn't test this but it should work in theory.

  3. #3
    Regular Contributor
    Join Date
    Mar 2005
    Location
    Hamburg, Germany
    Posts
    285

    Re: Dynamic image problem, src not recognized

    Thank you,
    setting the src is simplier than calling setAttributte. It works, but it gives the same strange result. (The scr attribute gets additional spaces after slashes in the debugger)

    I now found the a part of the problem: the server which serves the images sends a 500 internal error.
    When I open the url directly, it works. When I put a link to the url of the image in, it works, the S40 Webbrowser opens the image then.

    Unfortunately, the server is not in my control. When I put the images on my own server, it works.
    So this special server seem to not like some of the headers that are generated when the image is changed by javascript.

  4. #4
    Registered User
    Join Date
    Aug 2011
    Posts
    26

    Re: Dynamic image problem, src not recognized

    I'm sorry to hear that.
    Are you able to access the headers so you can compare them? I tested an example document on the Asha 303 emulator and both headers were the same.
    Btw: Which device/emulator are you using? (Could be useful to know if Nokia staff reads this)


    Edit: I thought of another thing: Probably the difference in your headers are actually the whitespaces in "http:/ / mydomain/ path".
    The first line of the header could be one of the following:
    GET http:/ / mydomain/ path HTTP/1.1
    GET http:/%20/%20mydomain/%20path HTTP/1.1
    GET mydomain/ path HTTP/1.1
    GET mydomain/%20path HTTP/1.1
    This seems to confuse the software running on the server you want to access.

    Or it could also be in the "Host:"-line.
    It would be interesting to see your headers.


    Summing up: I think that there is a bug in the browser you are testing with.
    Last edited by UnPlan2ned; 2012-05-19 at 19:36.

  5. #5
    Regular Contributor
    Join Date
    Mar 2005
    Location
    Hamburg, Germany
    Posts
    285

    Re: image problem, src not recognized

    Thank you for continuing support.

    Well, a response of 500 is per definition a web server problem. If there are bad parameters in the request, they should throw something like a 400 or 406 code.
    It seem to be a apache webserver behind some kind of load balancer (which may be the problem).

    Nevertheless, the problem may be triggered by some bad request parameters.

    I use Nokia WebTools 1.5 on Windows 7, in problem occurs both in local simulator and in cloud preview.

    The Debugger shows only a part of the request parameters, there everything looks ok (no spaces in path)
    The only unusual thing is the User Agent, maybe they don't like it that it does not contain "Mozilla (compatible, Internet Explorer (compatible ....." stuff. Instead it is
    "S40OviBrowser/1.0.0.9.10 Profile/MIDP-2.1 Configuration/CLDC-1.1 Series40 NokiaX3-02/05.60 WebSDKSimulator/1.5.0.201110122136"

    I can now also see this problem with a static image, so my problem has nothing to do with javascript. But when I set an link to the image, there is no problem displaying the image.

    My plan now: I will make some experiments with retrieving the images with a script where I can set the header.

  6. #6
    Registered User
    Join Date
    Aug 2011
    Posts
    26

    Re: image problem, src not recognized

    You are right, a 500 error can be caused by request parameters. That actually happened to me yesterday in an server-sided app I'm currently coding: It threw a 500 error because of a null-pointer exception. (I forgot to add code that checks if a specific parameter actually was submitted before attempting to print it.) Of course it can be another problem on the server you want to dynamically fetch an image.

    Quote Originally Posted by internetlabor View Post
    I can now also see this problem with a static image, so my problem has nothing to do with javascript. But when I set a link to the image, there is no problem displaying the image.
    Sorry, I don't get this part. What exactly do you call a "static image"?


    P.S.: Do you know by any chance which web-server is running on the server you want to access?

  7. #7
    Regular Contributor
    Join Date
    Mar 2005
    Location
    Hamburg, Germany
    Posts
    285

    Re: image problem, bad header content-type

    Finally I tracked the problem down.
    The web server has a problem with the header:

    Code:
    Content-Type: image/gif; q=0.5
    The Nokia debugger does NOT show all http-headers. I captured the http-requests of my simulator with the help of Microsoft Network Monitor.
    I wrote a ruby script to send requests myself. When I add the Content-Type Header, the server responds with 500. Without it, everything is ok.

    So there are two points
    1) The server is to blame, it has an error, it should not answer 500.

    2) But the Nokia Tool Chain seem to have a bug also. To me, there seem to be no reason to send this header.
    The header gets sended when I do a normal external static image, like this

    Code:
    <img src="http://domain/image.jpg">
    The image is jpg, not gif!
    Also, the content-type header in the request is to define body of the request. But there should be no body in this request, as I don't want to send an image, I want to receive an image. And the "q=0.5" makes only sense for the accept-header.

    http://www.w3.org/Protocols/rfc2616/....html#sec14.17

    I have investigated this problem in NokiaWDE 1.5 WebSDKSimulator. The error also happens in the cloud preview. But I can not do a network analysis there, but I expect it is same as the error is the same.

    Does anybody knows who to report bugs to Nokia nowadays?

  8. #8
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: image problem, bad header content-type

    Hi,

    Sorry for late reply, I have been busy with other projects.
    I just started to investigate this, but you already managed to solve it.
    Yes additional tools such as Fiddler are helpful for debugging situations like this.

    I can make the bug report for you to ensure that this issue will be addressed ASAP.

    Could you PM me the server URL, so we can run a test against it?

    Br,
    Ilkka

  9. #9
    Registered User
    Join Date
    Aug 2011
    Posts
    26

    Re: image problem, bad header content-type

    Interesting - I haven't thought of that.

    But still, why does it sometimes put spaces in the path?
    Last edited by UnPlan2ned; 2012-05-24 at 16:56.

  10. #10
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: image problem, bad header content-type

    Quote Originally Posted by UnPlan2ned View Post
    Interesting - I haven't thought of that.

    But still, why does it sometimes put spaces in the path?
    Hi,

    Could you tell more about the case where you see spaces in the path?

    Br,
    Ilkka

  11. #11
    Registered User
    Join Date
    Aug 2011
    Posts
    26

    Re: image problem, bad header content-type

    I was refering to the first post by internetlabor
    Quote Originally Posted by internetlabor View Post
    [..]

    Second try:
    create the image tag as string <image src=I change src=""> and add it to the wrapping div with innerHTML(). This adds an image, but the url is not recognized.
    In the debugger I see either the src attribut with spaces inserted after slashes
    "http://mydomain/path" -> "http:/ / mydomain/ path",
    or in the properties debugger dialog I see an empty src property.
    [..]

  12. #12
    Registered User
    Join Date
    Jul 2012
    Posts
    5

    Re: Dynamic image problem, src not recognized

    use full path bro...

Similar Threads

  1. Replies: 6
    Last Post: 2011-01-13, 12:59
  2. Add image to Dynamic Form ???
    By Shilpa13 in forum Symbian User Interface
    Replies: 0
    Last Post: 2006-05-04, 11:40
  3. Dynamic image in .dm-file ?
    By asaaheim in forum Digital Rights Management & Content Downloading
    Replies: 6
    Last Post: 2006-04-03, 09:37
  4. dynamic image loading
    By mfcguru in forum Mobile Java General
    Replies: 3
    Last Post: 2005-11-30, 13:56

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×