I just came around something with jQuery that is somewhat discouraging
after all the positives I have been experiences with jQuery.
Maybe there is an answer to this.
One of the "selling points" I had plans to make in helping to introduce
and promote AJAX into our package and to our customers was a illustrate
quick implementations of AJAX to embed other existing URL displays in
"windows" on the same page.
A good example is the "top stories" right-side box display at:
http://www.winserver.com
which was quickly added to the index page using a div container and a
simple JS raw AJAX call:
<div id="TopStories" style="width:20%; float:left;"></div>
<script>
if (document.getElementById) {
var x = (window.ActiveXObject)?
new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
}
if (x) {
x.onreadystatechange = function() {
if (x.readyState == 4 && x.status == 200) {
var el = document.getElementById("TopStories");
if (el) el.innerHTML = x.responseText;
}
}
x.open("GET", "/public/code/html-topstories.wcx");
x.send(null);
}
</script>
In short, I was beginning to hype the "neat" idea in our support forums
that web authors can quickly add AJAX displays using existing stock WCX
urls and I used quick examples like the above. (Note: WCX is to our
webserver, what ASP is to IIS, what PHP is to other web servers, etc.).
When I found jQuery, I used this example to see if its advertised motto
"write less, do more" was true.
So I replaced the above with this:
<script language="javascript" src="/public/js/jquery.js"></script>
<script>
$(document).ready(function() {
$('#TopStories').load('/public/code/html-topstories.wcx');
});
</script>
and behold! It worked! I was tickled pink!!! Maybe I found the right
library! Its seems popular and top not engineers behind it! It seems to
be well supported too!
But I continued looking around and a few days ago, I found protocol.js.
I created a protocol.js version of the above:
<script language="javascript" src="/public/js/protocol.js"></script>
<script>
new Ajax.Updater('TopStories', '/public/code/html-topstories.wcx');
</script>
and it worked just the same!
The problem?
Well, I began to explore other more sophisticated WCX request we have
that does more and some even have JS in it.
For example, we have one WCX, "/code/html-who.wcx" that displays the
active users online and with JS, SPLASH, ACTIVEX or JAVA it uses audio
notifications like "You have new Mail".
Here is what I found using the 3 methods when requesting this
HTML-WHO.WCX url:
Raw Ajax --> Displays not JS elements were ignored. of course.
Protocol.js --> Displays it properly,no delays, but no sound.
jQuery: --> No Display, in fact, the browser seems slower.
I think with protocol.js, it had a problem resolved the base path for
the embedded JS.
With jQuery, I had to "stop" the loading because it just seem lost, the
FF browser was slowed. It seem stuck in some loop.
Now, I am not 100% sure why this happen with jQuery, but I guess I need
to ask the following:
What are the limitations of use jQuery AJAX calls to
URLs which has JS as well?
In this case, the WCX loads "soundmanager.js" which is a MP3 player library.
Thanks
--
HLS