473,503 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem updating an image through js

Note that captcha.php, generates a png image. I know it works well,
beacause in page load, I've
<img id="mainimage" src"simplecaptcha/captcha.php">
and the image is generated as expected,

but as soon as I want to reload the image, I can't
Note that I tried both with absolute and relative paths to the php
file, and neither work
<a href="javascript:void(0)" onclick="ReloadCaptcha();">give me an
easier one!</a>
<script type="text/javascript">

function ReloadCaptcha(){
alert ('ReloadCaptcha');

///document.getElementById('mainimage').src='http://MYSITE/simplecaptcha/captcha.php';
document.getElementById('mainimage').src='simpleca ptcha/captcha.php';
return true;
}
</script>

Jul 18 '06 #1
2 1589
Rik
ju*******@gmail.com wrote:
Note that captcha.php, generates a png image. I know it works well,
beacause in page load, I've
<img id="mainimage" src"simplecaptcha/captcha.php">
and the image is generated as expected,

but as soon as I want to reload the image, I can't
Note that I tried both with absolute and relative paths to the php
file, and neither work
<a href="javascript:void(0)" onclick="ReloadCaptcha();">give me an
easier one!</a>
<script type="text/javascript">

function ReloadCaptcha(){
alert ('ReloadCaptcha');

///document.getElementById('mainimage').src='http://MYSITE/simplecaptcha/cap
tcha.php';
>

document.getElementById('mainimage').src='simpleca ptcha/captcha.php';
return true;
}
in captcha.php:

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>

Which isn't always obeyed be browsers.

You could create a random number, and set the source to
captcha.php?cachebypass=random_number
--
Rik Wasmus
Jul 19 '06 #2

Rik wrote:
ju*******@gmail.com wrote:
Note that captcha.php, generates a png image. I know it works well,
beacause in page load, I've
<img id="mainimage" src"simplecaptcha/captcha.php">
and the image is generated as expected,

but as soon as I want to reload the image, I can't
Note that I tried both with absolute and relative paths to the php
file, and neither work
<a href="javascript:void(0)" onclick="ReloadCaptcha();">give me an
easier one!</a>
<script type="text/javascript">

function ReloadCaptcha(){
alert ('ReloadCaptcha');
///document.getElementById('mainimage').src='http://MYSITE/simplecaptcha/cap
tcha.php';


document.getElementById('mainimage').src='simpleca ptcha/captcha.php';
return true;
}

in captcha.php:

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>

Which isn't always obeyed be browsers.

You could create a random number, and set the source to
captcha.php?cachebypass=random_number
I solved it doing this way
document.getElementById('mainimage').src='http://REALPATH/captcha.php?'
+ Math.random();

Doing that, I create everytime a "new" url. That seems to be the reason
why it works.

Anyway, thanks for your answer

regards - julian

Jul 19 '06 #3

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

Similar topics

0
1437
by: MicFra | last post by:
hi, i got a little problem with pdf-serializing after updating from cocoon 2.1.2 to 2.1.4. following scenario: - using serializer org.apache.cocoon.serialization.FOPSerializer, with name...
0
2597
by: Vladimir Kanovnik | last post by:
I have table with columns id(number), photo(blob) and thumbnail(blob). I would like to insert image (using stored procedure) from file to column photo and in same time copy reduced image to column...
4
2280
by: kieran5405 | last post by:
Hi, I have an Intranet page that has an image that changes each day, but the image is caching and not updating until the user manually does a page refresh. I want the page to refresh itself but...
5
2412
by: Mike Dole | last post by:
When I am updating a picturebox with an image (extracted) from an access database I keep getting a "The process cannot access the file "c:\foto1.jpg because it is being used by another process"...
2
1627
by: victor | last post by:
Hello, I'm running an ASP.NET client app which requests a jpg image from the server location. This image file is constantly updated by another app at the same server machine - update frequency...
12
2271
by: Justin | last post by:
I can attach my code if anyone wants to see it however I'll try to ask my question with some mark up code first. I'm having a problem terminating my process while using DoEvents. For example: ...
4
13409
by: Jerry West | last post by:
I have a routine that updates a PictureBox image every x seconds. I do this by first loading an array with the path to all of the images. I then generate a random number to use as the index of the...
16
2954
by: Stevo | last post by:
I'm guessing this is a laughably obvious answer to many here, but it's not to me (and I don't have a server or any knowledge of PHP to be able to try it). It's not strictly a PHP question, but...
0
7205
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
7093
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
7287
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
7349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5022
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...
0
3177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
399
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.