I have the following code, which will not work. The javascript gives no errors and appears to load fine. but clicking on a link will do nothing. An example of a link is:
<a href='#' onclick='updateByQuery('Layer3', 'Ed Hardy');'>Link 1</a><li>Link 2</li>
and the code:
var xmlHttp var layername var url function update(layer, url) { var xmlHttp=GetXmlHttpObject(); //you have this defined elsewhere if(xmlHttp==null) { alert('Your browser is not supported?'); } xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState==4 || xmlHttp.readyState=='complete') { document.getElementById(layer).innerHTML=xmlHttp.responseText; } else if (xmlHttp.readyState==1 || xmlHttp.readyState=='loading') { document.getElementById(layer).innerHTML='loading'; } //etc } xmlHttp.open('GET',url,true); xmlHttp.send(null); } function updateByPk(layer, pk) { url = 'get_auction.php?cmd=GetAuctionData&pk='+pk+'&sid='+Math.random(); update(layer, url); } function updateByQuery(layer, query) { url = 'get_records.php?cmd=GetRecordSet&query='+query+'&sid='+Math.random(); update(layer, url); } function GetXmlHttpObject() { var xmlHttp=null; try { xmlHttp=new XMLHttpRequest(); }catch (e) { try { xmlHttp =new ActiveXObject('Microsoft.XMLHTTP'); } catch (e) {} } return xmlHttp; } function makewindows(){ child1 = window.open ('about:blank'); child1.document.write(<?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']), ENT_QUOTES); ?>); child1.document.close(); }
It may probably be due to the double-quote characters surrounding ‘Ed Hardy’. Does this work: