Is it possible to execute javascript as passed in xmlHttp.respons eText
Here is what I am doing:
search.js
var xmlHttp
xmlHttp=GetXmlH ttpObject()
var url="search.php "
xmlHttp.onready statechange=sta teChanged
xmlHttp.open("G ET",url,true)
xmlHttp.send(nu ll)
function stateChanged()
{
if (xmlHttp.readyS tate==4 || xmlHttp.readySt ate=="complete" )
{
document.getEle mentById("searc h").innerHTML=x mlHttp.response Text;
}
}
function GetXmlHttpObjec t()
{
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.XMLHT TP");
}
}
return xmlHttp;
search.php
<script type="text/javascript">
alert("hi");
</script>
<?php echo "hi"; ?>
test.php
<script src="search.js" ></script>
<div id=livesearch></div>
So what I see when I browse to test.php is 'hi' printed to the
browser, but I would also expect to have the javascript alert executed
If I visit search.php then I get 'hi' printed to the browser and the
alert message
So it seems that when I pass the response to the span the javascript
alert is ignored
(document.getEl ementById("sear ch").innerHTML= xmlHttp.respons eText;)
Sp my question is how can I have javascript be passed and executed?
Thanks!