Hello!
I have a index.php that on one click calls via AJAX a file.php.
index.php looks like this:
<html >
<head>
<script language="javas cript" type="text/javascript" >
var http; // We create the HTTP Object
var dest;
var prenosi;
function getHTTPObject() {
var xmlhttp;
/*@cc_on
@if (@_jscript_vers ion >= 5)
try {
xmlhttp = new ActiveXObject(" Msxml2.XMLHTTP" );
} catch (e) {
try {
xmlhttp = new ActiveXObject(" Microsoft.XMLHT TP");
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest( );
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
function processStateCha nge(){
if (http.readyStat e == 4){
contentDiv = document.getEle mentById(dest);
if ((http.status == 200)||(http.sta tus==0)){
response = http.responseTe xt;
contentDiv.inne rHTML = response;
} else {
contentDiv.inne rHTML = "Error: Status "+http.stat us;
}
}
}
function loadHTML(URL, destination){
dest = destination;
var url;
http = getHTTPObject() ;
if(http){
http.onreadysta techange = processStateCha nge;
http.open("GET" , URL, true);
http.send(null) ;
}
}
</head>
<body>
<span onclick="loadHT ML(file.php','' )">Click</span><br>
</html>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - -
file.php looks like this:
<span id="countdownco ntainer">
write something down
<script type="text/javascript">
document.write( "1")
</script>
</span>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - -
The problem is that "write something down" displays on the Internet
Explorer, but number 1 doesn't. If we call just file.php - it works then -
it displays both. Why is javascript not executing from ajax called
procedure?
Ivan Petrovic
I have a index.php that on one click calls via AJAX a file.php.
index.php looks like this:
<html >
<head>
<script language="javas cript" type="text/javascript" >
var http; // We create the HTTP Object
var dest;
var prenosi;
function getHTTPObject() {
var xmlhttp;
/*@cc_on
@if (@_jscript_vers ion >= 5)
try {
xmlhttp = new ActiveXObject(" Msxml2.XMLHTTP" );
} catch (e) {
try {
xmlhttp = new ActiveXObject(" Microsoft.XMLHT TP");
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest( );
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
function processStateCha nge(){
if (http.readyStat e == 4){
contentDiv = document.getEle mentById(dest);
if ((http.status == 200)||(http.sta tus==0)){
response = http.responseTe xt;
contentDiv.inne rHTML = response;
} else {
contentDiv.inne rHTML = "Error: Status "+http.stat us;
}
}
}
function loadHTML(URL, destination){
dest = destination;
var url;
http = getHTTPObject() ;
if(http){
http.onreadysta techange = processStateCha nge;
http.open("GET" , URL, true);
http.send(null) ;
}
}
</head>
<body>
<span onclick="loadHT ML(file.php','' )">Click</span><br>
</html>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - -
file.php looks like this:
<span id="countdownco ntainer">
write something down
<script type="text/javascript">
document.write( "1")
</script>
</span>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - -
The problem is that "write something down" displays on the Internet
Explorer, but number 1 doesn't. If we call just file.php - it works then -
it displays both. Why is javascript not executing from ajax called
procedure?
Ivan Petrovic
Comment