q-rious said:
q-rious meinte:
Just to confirm, you mean something like this from the PHP side:
echo "[all javascript here]";
Right?
Yes.
[...]
Please trim your quotes to the minimum required to retain context;
do not quote signatures (unless you refer to them).
[...] I tried to use JS Image object,
There is no such thing really. `Image' was part of the JavaScript
programming language from version 1.1 to 1.3 only because JavaScript was
associated with a single DOM API then, that of Netscape Navigator.
Since JavaScript 1.4, host objects like `Image' have been removed from the
JavaScript programming language, its reference material thus being renamed
from *Client-Side* JavaScript Reference (1.3) to *Core* JavaScript Reference
(1.4+). While those host objects are still supported for backwards
compatibility and lack of alternatives, the Gecko DOM provides the API instead.
In other ECMAScript implementations, such as Microsoft JScript as
implemented by MSHTML/IE, (until proof to the contrary is presented) this
feature and other features have never been part of the programming language
but of the object model of one corresponding host environment, the MSHTML
DOM, instead.
but I do not think this is working for me. The PHP code (loadXML.php) is
working for me correctly standalone. It correctly writes low, high
etc. in that case.
But when I use the following code, image.complete is never true.
So as `Image' is a host object and not part of any public standard, it is
implemented differently by user agents, and several of its properties,
including `complete', are either deprecated or obsolete nowadays.
Since you have neither told which environment (browser) you have tested with
nor have you posted the URL of a test case (and so there is no way to refute
or back up your claims), one has to assume that either loading the image
never completes or that the `complete' property is unsupported there. If
the latter, there are two likely possibilities: either it would yield `true'
always, such as in Fx 3, or `undefined' which is never strictly equal to `true'.
Your best chance of detecting whether an Image object has completed loading
the image data is to use the proprietary `onchange' event handler property
instead:
var img = new Image();
img.onload = function() {
window.alert("image loaded");
};
img.src = "...";
(You could also try the standards-compliant `load' event instead, but the
MSHTML DOM does not implement W3C DOM Level 2+ Events and the corresponding
methods.)
//------------------ PHP STARTS HERE ------------------------
var myImage = new Image();
myImage.src = "loadXML.php?thisZip=" + str_val;
//------------------ PHP ENDS HERE ------------------------
This is not PHP code.
HTH
PointedEars