VK wrote:[color=blue]
> Not sure if you want a working solution or hints for the solution.
> Presuming the latter (but OK to write for you the first, but it's going
> to be my code sorry - with almost nothing left of yours :-) :-([/color]
yes, I am looking for hints because I'm trying to understand the
specific object but how things are done in JavaScript. It's been years
since I've done any significant coding (reasons too boring to explain)
except for a couple projects in Python.
some of the sins you point out come from copying an example without
understanding the environment fully. based on your subsequent comments,
it's quite clear that the JavaScript documentation on the net is almost
entirely comprised of bad examples and incomplete information.
http://www.degraeve.com/reference/si...ax-example.php
[color=blue]
> 1. "self" is a very bad indentifier because host object "window" has
> self-reference property .self[/color]
I thought that was the case. I was wondering why the example assigned
this to self. What is this then??
[color=blue]
> So you are risking to get window reference instead of object reference
> - and no error shown, just results far of expected. Just try to call
> processtab() as a simple function and put something like:
> if (window.XMLHttpRequest) {
> // added:
> alert(self.navigator);
> //
> self.xmlHttpReq = new XMLHttpRequest();
>
> Do you really need such ambiguity?[/color]
no. I would prefer to something like:
request = new XMLHttpRequest();
(by the way, I really hate these bumpy caps. It's really hard to speak
them with speech recognition with all of the <caps> <no space>
additional utterances necessary to form such symbols.)[color=blue]
>
> 2. xmlHttpReq is created as local variable within processtab() if you
> call it as constructor. Or as window property if you call it as regular
> function.
>
> You should really create either a singleton (JS-kind, still can be
> cloned, but close by functionality):
>
> var xmlHttpReg = {
> 'reg' : // here XMLHttpRequest object
> 'send' : // here your send method
> };
> where later xmlHttpReg.send(args);
>
>
> or a regular constructor:
>
> function xmlHttpReg() {
> this.$ = // XMLHttpRequest object;
> this.send = // here your send method
> }
> where later
> glbRequest = new xmlHttpRequest();
> glbRequest.send(args);[/color]
is this stuff documented anywhere? I mean something readable like K&R
because I really don't understand the syntax. It looks like you are
assigning into an associative array? what's wrong with creating an
instance of XMLHttpRequest and just using the methods off of that? If
it needs to persist, assign the instance to a global.
[color=blue]
> 3. Browser updates the graphics context only after the exit from the
> script execution. So you need to give a micro-break in your loop if you
> want table rows disappear one by one on each call. That brings the
> setTimeout method into the loop, breaks context (because of
> incontinence of "this"), a bounch of other interesting things and
> finally - the old lore that it is alweays better to write one sub doing
> one thing rather then one sub doing 2-3-... things :-)[/color]
okay. This is the point where I've made up my mind to abandon the
project. I don't have the resources to spend any more time on it since
its for an open source project and it's taking me away from billable work.
I was hoping for a way to convert this back to a simple iterative
process but it looks like in order to do so, I would need to either to
go to synchronous mode and all of its problems that I would experience
with process with a total running time of a few seconds to a couple of
minutes or maybe a semaphore between the callback method assigned to
onreadystatechange and the main loop sending the data.
I appreciate the help and it has taught me a lot. I think I'm going to
move instead to shoving all the training requests into a queue on the
server and making the user think the work has been done.
[color=blue]
> P.S. Do I think that IXMLHTTPRequest / XMLHttpRequest is unnecessary
> over-complicated? Yes I do. I would prefer to see something not so
> low-level boring. Something like "download" behavior in IE, where you
> simply tell what to get, what function to call when done and what
> function to call if failed.
> But from the other side developers want to eat too, and who will pay
> good bucks for "Ajax solution" if anyone can make it in few keypress?
> ;-)[/color]
hey, if I had money and authorization to spend it on a JavaScript
developer, I would do so. But this is an open-source project
(camram.org), it's coming out of my own pocket and I just don't have the
resources be it time or money right now to go any further.
again, many thanks for the help. I do appreciate it and sometimes
knowledge of when to quit is more important than getting to where you
want to be.
---eric