M
Mike
Hello,
I am trying to update a child window jpg with JavaScript I seam to get
my error in the Ajax.
Ive used this, and it works, if I want to write to the same window,
but not a new one
Doesnt Work:
newWindow.write(newWindow.getElementById("Graph").src = imageName);
Doesnt Work:
newWindow.getElementById("Graph").src = imageName;
The Entire .js (URL MODIFIED) below. imagename does come back with
exactly what I want.
var xmlHttp;
var newWindow;
function NewGraphWindow(a,b){
if (!newWindow || newWindow.closed) {
newWindow = window.open
("","Graph","status,height=600,width=650");
// delay writing until window exists in IE/Windows
writeToWindow(a,b);
//setTimeout("writeToWindow()", 50);
} else if (newWindow.focus) {
writeToWindow(a,b);
//alert("Window is already opened");
// window is already open and focusable, so bring it to
the front
newWindow.focus();
}
}
function writeToWindow(a,b) {
// assemble content for new window
var newContent = "<html><head><title>Secondary Window</title></
head>";
newContent += "<body>";
newContent += "<img src='petatat.jpg' width='650px'
id='Graph' />";
newContent += "</body></html>";
//process(a,b);
// write HTML to new window document
newWindow.document.write(process(a,b));
newWindow.document.write();
newWindow.document.close(); // close layout stream
// process(a,b);
}
function process(a,b)
{
alert(a);
xmlHttp=GetXmlHttpObject();
//alert(xmlHttp)
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="http://xxxxxxxxxx/GraphDiv.php"
url=url+"?U="+a+"&SType="+b;
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
xmlHttp.onreadystatechange=stateChanged
}
function stateChanged()
{
if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
{
// status of 200 indicates the transaction completed successfully
if (xmlHttp.status == 200)
{
// extract the XML retrieved from the server
xmlResponse = xmlHttp.responseXML;
alert(xmlResponse);
// obtain the document element (the root element) of the XML
structure
xmlDocumentElement = xmlResponse.documentElement;
alert(xmlResponse.documentElement);
// get the jpgraph jpg filename, which is in the first child of
// the the document element
imageName = xmlDocumentElement.firstChild.data;
alert(imageName);
// set the src parameter of the image to the retrieved image
name
//document.getElementById("Graph").src = imageName;
newWindow.write(newWindow.getElementById("Graph").src =
imageName); THIS IS WHERE I GET MY ERROR
//newWindow.getElementById("Graph").src = imageName;
alert (newWindow.getElementById("Graph").src);
alert(imageName);
}
// a HTTP status different than 200 signals an error
else
{
setTimeout('stateChanged()', 100);
}
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
I am trying to update a child window jpg with JavaScript I seam to get
my error in the Ajax.
Ive used this, and it works, if I want to write to the same window,
but not a new one
Doesnt Work:
newWindow.write(newWindow.getElementById("Graph").src = imageName);
Doesnt Work:
newWindow.getElementById("Graph").src = imageName;
The Entire .js (URL MODIFIED) below. imagename does come back with
exactly what I want.
var xmlHttp;
var newWindow;
function NewGraphWindow(a,b){
if (!newWindow || newWindow.closed) {
newWindow = window.open
("","Graph","status,height=600,width=650");
// delay writing until window exists in IE/Windows
writeToWindow(a,b);
//setTimeout("writeToWindow()", 50);
} else if (newWindow.focus) {
writeToWindow(a,b);
//alert("Window is already opened");
// window is already open and focusable, so bring it to
the front
newWindow.focus();
}
}
function writeToWindow(a,b) {
// assemble content for new window
var newContent = "<html><head><title>Secondary Window</title></
head>";
newContent += "<body>";
newContent += "<img src='petatat.jpg' width='650px'
id='Graph' />";
newContent += "</body></html>";
//process(a,b);
// write HTML to new window document
newWindow.document.write(process(a,b));
newWindow.document.write();
newWindow.document.close(); // close layout stream
// process(a,b);
}
function process(a,b)
{
alert(a);
xmlHttp=GetXmlHttpObject();
//alert(xmlHttp)
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="http://xxxxxxxxxx/GraphDiv.php"
url=url+"?U="+a+"&SType="+b;
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
xmlHttp.onreadystatechange=stateChanged
}
function stateChanged()
{
if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
{
// status of 200 indicates the transaction completed successfully
if (xmlHttp.status == 200)
{
// extract the XML retrieved from the server
xmlResponse = xmlHttp.responseXML;
alert(xmlResponse);
// obtain the document element (the root element) of the XML
structure
xmlDocumentElement = xmlResponse.documentElement;
alert(xmlResponse.documentElement);
// get the jpgraph jpg filename, which is in the first child of
// the the document element
imageName = xmlDocumentElement.firstChild.data;
alert(imageName);
// set the src parameter of the image to the retrieved image
name
//document.getElementById("Graph").src = imageName;
newWindow.write(newWindow.getElementById("Graph").src =
imageName); THIS IS WHERE I GET MY ERROR
//newWindow.getElementById("Graph").src = imageName;
alert (newWindow.getElementById("Graph").src);
alert(imageName);
}
// a HTTP status different than 200 signals an error
else
{
setTimeout('stateChanged()', 100);
}
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}