Hi guys,

I'm using ajax to display the xml file. On my html i put

<body onload="sendRequest(Display)">

so everytime users go to the main.html, all the information in xml will be displayed after transformed by XSL

Now the problem is it gets the error

Display is not defined

While i did define it in js file

this is what I do in js;

var xhr = createRequest();
function sendRequest(data)
{
	if(xhr) {
		xhr.open("GET","product.php?id=" + Number(new Date) +"&value=" + data, true);
		xhr.onreadystatechange = function() {
		if (xhr.readyState == 4 && xhr.status == 200) {
			var divtag = document.getElementById("product");
			divtag.innerHTML = xhr.responseText;
			}
		}
	xhr.send(null);
	}
}

xhr has another file for it*

in php file;

<?php 
switch($_GET['value']) {
	case 'Display':
		
		$xsl = new DOMDocument;
		$xsl->load('product.xsl');

		
		$processor = new XSLTProcessor;

		
		$processor->importStyleSheet($xsl);

		
		$xml = new DOMDocument('1.0');
		$xml->load('items.xml');

		
		$transformedXml = $processor->transformToXml($xml);
		
		echo($transformedXml);
	break;

}
?>

in my xsl;

<xsl:for-each select="items/item">
	  <xsl:value-of select ="manufacturer" />
	  </xsl:for-each>

Can anyone tell me what's wrong with the code?

Thanks in advanced.

<body onload="sendRequest(Display)">

<body onload="sendRequest('Display')">

<body onload="sendRequest('Display')">

ah
stupid mistakee!
thxxx fxm

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.