473,399 Members | 4,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

AJAX and dynamic images

Hello,

I am developing in ASP.NET 1.1 (and unfortunately I am obliged to use
1.1).

I need to generate images, using GDI+ and retrieve them on the web
page, using AJAX.

On the server side, I have a ASPX page that generates the bitmap and
has to return it, when invoked by the client, via AJAX (XMLHTTP). Here
is the last part of the source code:

((System.Drawing.Image)bmpNewBitmap).Save(Response .OutputStream,
System.Drawing.Imaging.ImageFormat.Jpeg);
//-- let the browser know we are sending an image, and that things are
200 A-OK
Response.ContentType = "image/jpeg";
Response.StatusCode = 200;
Response.End();

On the client side, the invocation of the ASPX page was:

xhr_object = GetXMLHttpRequest();
var full_url = url + '?ImageParams=' + _imgParams;
//_imgParams contains information that are used by the ASPX page to
generate the image.
xhr_object.onreadystatechange = ProcessAJAXResponse;
xhr_object.open("GET", full_url, true);
xhr_object.send(null);

In the ProcessAJAXResponse() function, I attempt to display the
generated image like this:

function ProcessAJAXResponse() {
if (xhr_object.readystate == 4) {
if (xhr_object.status == 200) {
document.getElementById('imgDynamic').innerHTML =
xhr_object.responseBody;
}
}

The placeholder for the image is, in the page,
<img id='imgDynamic'>

-------------------------

I tried using xhr_object.responseText but it does not work neither.
I also tried using .src =document.getElementById('imgDynamic').src =
xhr_object.responseBody; but it does not work neither...
Could someone give me some help?

In advance, many thanks.

Didier

Dec 6 '06 #1
2 1551
Hi,

boeledi wrote:
Hello,

I am developing in ASP.NET 1.1 (and unfortunately I am obliged to use
1.1).

I need to generate images, using GDI+ and retrieve them on the web
page, using AJAX.

On the server side, I have a ASPX page that generates the bitmap and
has to return it, when invoked by the client, via AJAX (XMLHTTP). Here
is the last part of the source code:
<snip server-side code>

On the client side, the invocation of the ASPX page was:

xhr_object = GetXMLHttpRequest();
var full_url = url + '?ImageParams=' + _imgParams;
//_imgParams contains information that are used by the ASPX page to
generate the image.
xhr_object.onreadystatechange = ProcessAJAXResponse;
xhr_object.open("GET", full_url, true);
xhr_object.send(null);
The nice thing with Image objects in the DOM is that they generate their
own request when you set the src property. So you don't need to generate
your XmlHttpRequest, just let the image do it. That's AJAX for dummies ;-)

var img = document.getElementById( 'imgDynamic' );
if ( img )
{
img.src = full_url;
}

That should work.
In the ProcessAJAXResponse() function, I attempt to display the
generated image like this:

function ProcessAJAXResponse() {
if (xhr_object.readystate == 4) {
if (xhr_object.status == 200) {
document.getElementById('imgDynamic').innerHTML =
xhr_object.responseBody;
}
Images are...images, so they don't have an HTML content...
}

The placeholder for the image is, in the page,
<img id='imgDynamic'>
I would set the src attribute to a default, for example a white
background placeholder.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Dec 6 '06 #2
Laurent,

Many thanks for your clear answer. It seems that I still have much to
learn about DOM... ;o))

I will implement your answer.

Dec 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: JMB | last post by:
Hello, I was wondering if anyone knew of any projects extending the inline upload progress bar to utilize an inpage image uploader with bar, without having to refresh or go to a seperate page,...
0
by: arunprabu | last post by:
Hi, I have a problecm with the AJAX request in my webpage. I have some filters on top of the page. I have a submit button and an empty div below the filters. Some of the filters have ajax...
1
by: www.web20developers.com | last post by:
http://www.web20developers.com http://www.web20developers.com/index.php?option=com_content&task=view... Ajallerix : AJAX, simple, fast Web image gallery demo ; at Novell AJAX -...
3
by: kksandeep | last post by:
i am using this three files to uplod file. i got this file from net but i think these have some error. i am new to this field plz help the script i found is some helpful but not too that i need ...
1
by: kksandeep | last post by:
i am using this three files to uplod file. i got this file from net but i think these have some error. i am new to this field plz help the script i found is some helpful but not too that i need ...
8
by: jackrabbithanna | last post by:
I'm using a ajax script the uses a tabbed div that fetches a remote webpage to display for each tab.when clicked. the script works fine except for one thing. The content of the page i want to...
11
by: burtonfigg | last post by:
I've read this article: http://www.oracle.com/technology/pub/articles/oracle_php_cookbook/ullman-ajax.html And from reading it thought it'd be interesting to try a bit of Ajax on my site. ...
4
by: pablorp80 | last post by:
Hello, Here is what I need: I need the focus and the cursor set to a textbox named txtGT, every time no matter if it is the first page load or whether it is a postback. Here is the problem: I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.