SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
Thread: simple ajax script help
-
Jul 4, 2008, 07:44 #1
simple ajax script help
so i have a this simple ajax code:
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;
}
function startbreak1(submitUser1breakStart){
xmlHttp=GetXmlHttpObject();
url = "postme.php?submitUser1breakStart="+submitUser1breakStart;
xmlHttp.open("GET", url ,true);
xmlHttp.onreadystatechange=
function(){
if (xmlHttp.readyState==4){
response=xmlHttp.responseText;
if (response.length>0){
document.getElementById('span1stBreak').innerHTML = response;
}else{
document.getElementById('span1stBreak').innerHTML = "";
}
}else{
document.getElementById('span1stBreak').innerHTML = "<strong>... loading</strong>";
}
};
xmlHttp.send(null);
}
* my dilema is that when postme.php loads in the span from the main page, it does not interpret javascripts, all it does is interpret the php codes there. pls help im a newbie in using ajax and i would really appreciate the help. thanks a bunch!
here is some scripts in postme.php
<html>
<head>
<script>
function sample() {
//simple alert will do.
alert("hi!!");
}
</script>
<body>
<?php
echo "blah blah";
?>
<script>
sample();
</script>
</body>
</head>
</html>
-
Jul 5, 2008, 06:56 #2
- Join Date
- Jun 2008
- Location
- Hyderabad
- Posts
- 252
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Scripts in Ajax Response will not work until you evaluate them. In third party libraries( like jQuery and Prototype), they will automatically evaluate JavaScript in Ajax response.
Bookmarks