View Full Version : extract an image from a web service
21 Jun 2011, 2:51 PM
I have a web service which gives be just an image...i.e. a web service just returns this
<img src="tmpcharts/cd__188.8.131.525115366001308696518_0.png" />
How do I show this image into a panel.
Please reply asap. Thanks for help.
21 Jun 2011, 3:56 PM
Is it the same domain as the app? If so, just use an AJAX request to get this HTML fragment and .update() the panel with it.
If it's not the same domain, you'll have to have the service returning some sort of JSON-P payload wrapping this fragment.
Also check out the data-URL feature of src.sencha.io: http://docs.sencha.com/io/src/#data-urls if you need to programmatically access image data.
21 Jun 2011, 4:18 PM
Thank you for prompt reply.
When I put the service request url in the web browser address bar, it actually shows me the image in the browser. So, I want something similar to this. So, I want to extract that image and put it onto the panel. Is there a way to do so.
San Jose State Univ.
22 Jun 2011, 5:38 AM
Just to be clear... the service returns the HTML, not the raw image itself? As I suggested, use AJAX and then the update() method of the panel to put the HTML into it.
22 Jun 2011, 12:52 PM
I tried a lot...but no luck...my service call is like
when opened in a web browser the "view source" source gives just this...
<img src="tmpcharts/cd__184.108.40.20659272299081308775677_0.png" />
ajax request always fails...I think I am doing a cross domain request. But, the image is not absolute path, its downloading a raw image.
Could you please give me a sample code that I should work on.
22 Jun 2011, 1:15 PM
The browser could be faking the HTML. Can you just curl it on the command line:
curl -I http://yourservice.com/whatever
And see what the content-type header is.
Is the domain the same as the one you have your app on? There's no point pasting code until we know if we need cross domain support (e.g. JSONP or CORS vs AJAX)
22 Jun 2011, 1:49 PM
Yes, domains are different. So...is there any way to do it without changing the service?
22 Jun 2011, 2:07 PM
Without changing the service your only option is an iFrame I think:
html: "<iframe src='http://yourservice.com/...'> </iframe>"
22 Jun 2011, 2:37 PM
Thank you very much James. Actually, I changed the service to solve my problem.
30 Nov 2012, 5:31 AM
i m taking image from jsonp web service in string form , but not getting hoe to display that string on panel..
How can this be done?
Powered by vBulletin® Version 4.1.5 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.