Hi.
I’m using mootools ajax. and I’ve coded something like this:
[CODE]<script type=”text/javascript”>
new ajax (“file.php”, {
postBody: “value=” + $(‘firstValue’).value + “&value2=” + $(‘secondValue’).value,
update: $(‘textPart’),
onComplete: $(‘theImage’).src = ‘images/’ + $(‘firstValue’).value + ‘.jpg’,
});
</script>
file.php makes an image for me and that image url must be replaced with <img id=”theImage” …
So far the file.php works fine and generates the image but it takes 1-2 sec to do it. my ajax script replaces the new image url fine but BEFORE the php creates the file.
So HTML fails to show image, because the image url is updated faster than the image itself is there.
It seems like, as soon as I click the element to call this ajax function, the image url gets updated, that doesn’t sound ‘onComplete’ to me.
Why onComplete is not actually waiting for the whole thing to get its thing finished? and how can I fix this?
Thanks for your time
p.s I put sleep(2000); in the end of the php file, but nothing changed. (I don’t want to hold php script for 2 sec either)