Hi there, Just started to experiment with AJAX. At the moment I have a simple image with an onClick event ( makeRequest("radio.php")) in sidebar.php makeRequest is the JS/AJAX part which outputs radio.php in an innerHTML. I like the output be set to radio.php when an user has clicked on the image and browse other pages. Now everytime an user browse the image is shown and not radio.php any advice??
You may want to take a look at my AJAX guide in DP or post your codes here as Mad4 has mentioned to obtain better responses.
sure here's some code on radio.php <script language="JavaScript" type="text/javascript" src="ajaxFunctions.js"></script> <span id="radio" style="cursor: pointer; text-decoration: underline; background-color:#FFFFFF;" onclick="makeRequest('stream.php?nocache=<?php echo time();?>','radio')"> <img src="../imgs/radio.gif" alt="Listen"> </span> Code (markup): stream.php just the object code <OBJECT id="NSPlay" type="application/x-oleobject" width="240" height="53" align="center" standby="www.classic.com" ........... ............. <embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&ar=Media&sba=Plugin&" src="http://ip-address/" autostart="1" width="240" height="53" transparentatstart="0" animationatstart="0" showcontrols="1" showstatusbar="1" autosize="0" displaysize="0" audiostream="1" ></embed> </OBJECT> Code (markup): Now for the ajaxfunctions.js // JavaScript Document function makeRequest(url,layerName) { var http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari, ... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml'); // See note below about this line } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Giving up :( Cannot create an XMLHTTP instance'); return false; } http_request.onreadystatechange = function() { //alertContents(http_request); output(http_request,layerName); }; http_request.open('GET', url, true); http_request.send(null); } //Called every time our XmlHttpRequest objects state changes. function output(http_request,layerName) { //Check to see if the XmlHttpRequests state is finished. if (http_request.readyState == 4) { //Set the contents of our span element to the result of the asyncronous call. if (http_request.status == 200) { document.getElementById(layerName).innerHTML = http_request.responseText; } else { document.getElementById(layerName).innerHTML = "Sorry, currently unavailable"; } } } Code (markup):