On Aug 31, 6:38 pm, <[EMAIL PROTECTED]> wrote:
> as you suggested and while it does run the alert message, it
> still fails out on the document.getElementByID in the destination
> page with the same error: TypeError: document.getElementById("blah1")
> has no properties
>
> Would you be able to paste in your sample app that you created? I
> am probably missing something small.
<html>
<head>
<title>Blah Blah</title>
<style>
body {
margin-left: 5%; margin-right: 5%;
color: crimson; background:#1C1C1C;
}
#ajaxLoader {
text-align: center;
border: 1px solid silver;
color: yellow;
background: green;
float: right;
}
</style>
<script type='text/javascript' src="/public/js/jquery-1.1.4.js"></
script>
</head>
<body>
<h3>Kevin's Blah Test</h3>
<div id="destDiv1">
<script language="JavaScript">
var s = "";
s += "<div id='ajaxLoader'>";
s += "<img src='/public/js/loader.gif' alt='Loading...' />"
s += "</div>";
$("#destDiv1").html(s);
$.ajax({
url: '/public/blah1.htm?a=' + Math.random(),
type: 'GET',
dataType: 'html',
timeout: 60000,
error: function(a,b,c){
$("#destDiv1").html('Error loading channel'
+ a + "|" + b + "|" + c);
},
success: function(thehtml){
// do something with HTML
$("#destDiv1").html(thehtml);
}
});
</script>
</div>
</body>
</html>
Note:
The blah1.htm has this:
<div id="blah1"></div>
<script language="JavaScript">
alert("hi");
document.getElementById("blah1").innerHTML = "<strong>hi</strong>";
</script>
Other than clean up code, making easier to read, adding my loader.gif
plus style, it is pretty much the same code but use jQuery to add the
html() so that any script tags are executed.
If the problem persist, then you might want to describe the browser
you are testing it with. I tested the above with IE and FF.
Hope this helps
PS: It was ajaxing so fast with my local server, to see the loader in
action, what I did was wrap the $.ajax() in a timer like so:
setTimeout(function () {
.. the above ajax statement ..
},3000);
--
HLS