I
Ivan P
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="javascript" type="text/javascript" >
var http; // We create the HTTP Object
var dest;
var prenosi;
function getHTTPObject() {
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
function processStateChange(){
if (http.readyState == 4){
contentDiv = document.getElementById(dest);
if ((http.status == 200)||(http.status==0)){
response = http.responseText;
contentDiv.innerHTML = response;
} else {
contentDiv.innerHTML = "Error: Status "+http.status;
}
}
}
function loadHTML(URL, destination){
dest = destination;
var url;
http = getHTTPObject();
if(http){
http.onreadystatechange = processStateChange;
http.open("GET", URL, true);
http.send(null);
}
}
</head>
<body>
<span onclick="loadHTML(file.php','')">Click</span><br>
</html>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - -
file.php looks like this:
<span id="countdowncontainer">
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="javascript" type="text/javascript" >
var http; // We create the HTTP Object
var dest;
var prenosi;
function getHTTPObject() {
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
function processStateChange(){
if (http.readyState == 4){
contentDiv = document.getElementById(dest);
if ((http.status == 200)||(http.status==0)){
response = http.responseText;
contentDiv.innerHTML = response;
} else {
contentDiv.innerHTML = "Error: Status "+http.status;
}
}
}
function loadHTML(URL, destination){
dest = destination;
var url;
http = getHTTPObject();
if(http){
http.onreadystatechange = processStateChange;
http.open("GET", URL, true);
http.send(null);
}
}
</head>
<body>
<span onclick="loadHTML(file.php','')">Click</span><br>
</html>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - -
file.php looks like this:
<span id="countdowncontainer">
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