JS strangeness

P

Pink Pig

(I don't know if this question has been asked and answered many times,
since I just joined this group and haven't attempted to search the
archives.)

I have a page under construction which uses jQuery and is fairly
massive. When I run it locally under Firefox, everything works fine,
but when I run it on the host site, I frequently run into difficulties
of the following type. I have a $(document).ready() function that
references variables and elements defined either in other JS scripts
(inline), or in the HTML. Sometimes, but not always, a reference to
one of these variables or elements resolves to a null pointer, which
aborts the execution of my $(document).ready() function and causes FF
to get hung up in the wrong place. For example, I have a JS variable
called 'calimg', which is supposed to be a string containing the URL
of an image file, and if I look at the source, that is how it is
defined, in a script that is placed before the script containing the $
(document).ready() function. But often, Firebug reports that the
variable 'calimg' is not defined when the $(document).ready() function
runs. What is causing this, and what can I do about it?
 
T

Thomas 'PointedEars' Lahn

Pink said:
[...] But often, Firebug reports that the variable 'calimg' is not
defined when the $(document).ready() function runs. What is causing this,
and what can I do about it?

Get a minimum clue and don't rely on junk like jQuery.

<http://jibbering.com/faq/>


PointedEars
 
P

Pink Pig

Pink said:
[...] But often, Firebug reports that the variable 'calimg' is not
defined when the $(document).ready() function runs. What is causing this,
and what can I do about it?

Get a minimum clue and don't rely on junk like jQuery.

<http://jibbering.com/faq/>

PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee

This is really not a helpful response. You might at least point me to
the appropriate section of this massive document.
 
T

Thomas 'PointedEars' Lahn

Pink said:
Thomas said:
Pink said:
[...] But often, Firebug reports that the variable 'calimg' is not
defined when the $(document).ready() function runs. What is causing this,
and what can I do about it?
Get a minimum clue and don't rely on junk like jQuery.

<http://jibbering.com/faq/>
[...]

This is really not a helpful response. You might at least point me to
the appropriate section of this massive document.

Try the section about how to post properly; it will lead to everything else.


PointedEars
 
P

Pink Pig

Try the section about how to post properly; it will lead to everything else.
Sigh. I know how to post messages, and I've read the entire FAQ, none
of which appears to be relevant to the question that I asked. If you
know what the answer is, why don't you just tell me?
 
D

David Mark

(I don't know if this question has been asked and answered many times,
since I just joined this group and haven't attempted to search the
archives.)

Seems like that would be the best time to search the archives.
I have a page under construction which uses jQuery and is fairly
Oops.

massive. When I run it locally under Firefox, everything works fine,

Or so it might seem.
but when I run it on the host site, I frequently run into difficulties
of the following type. I have a $(document).ready() function that
references variables and elements defined either in other JS scripts
(inline), or in the HTML. Sometimes, but not always, a reference to
one of these variables or elements resolves to a null pointer, which
aborts the execution of my $(document).ready() function and causes FF
to get hung up in the wrong place. For example, I have a JS variable
called 'calimg', which is supposed to be a string containing the URL
of an image file, and if I look at the source, that is how it is
defined, in a script that is placed before the script containing the $
(document).ready() function. But often, Firebug reports that the
variable 'calimg' is not defined when the $(document).ready() function
runs. What is causing this, and what can I do about it?

Stop using jQuery. If you plan to deploy a "massive" Web application,
it would seem a good time to learn JavaScript. The people who wrote
jQuery never bothered and now you are compounding their mistakes.

The fact that your app "works" sporadically should come as little
surprise. And the fact that you can't debug your code or articulate
its problems does not bode well for its future.
 
T

Thomas 'PointedEars' Lahn

Pink said:
Sigh. I know how to post messages, and I've read the entire FAQ, none
of which appears to be relevant to the question that I asked.

No wonder you are unable to answer your question for yourself if you are
unable to make a text search for "post" and read material while gathering
its meaning.
If you know what the answer is, why don't you just tell me?

The answer is to get a minimum clue (so that you know what you are doing)
and not to use jQuery (a decision apparent to make when you have that
minimum clue). I believe I have given you that answer already.

Any other answer will either waste my time debugging your code and allow you
to continue using jQuery in the process which would be a Bad Thing, or will
be likely not to be understood by you as you are lacking the minimum clue
required for that.


PointedEars
 
P

Pink Pig

On Jul 27, 3:20 pm, Thomas 'PointedEars' Lahn <[email protected]>
wrote:> Try the section about how to post properly; it will lead to everything else.

Sigh. I know how to post messages, and I've read the entire FAQ, none
of which appears to be relevant to the question that I asked. If you
know what the answer is, why don't you just tell me?

OK, there are now two people on my list of programmers I would never
hire. Any other volunteers, or does somebody want to be informative
rather than snide?
 
R

Richard Cornford

Pink said:
(I don't know if this question has been asked
and answered many times,

Which question? The question you asked, which is effectively ' I have
done something and the outcome is inconsistent', or a question about the
issue that underlies your question?
since I just joined this group and haven't attempted to
search the archives.)

That is unlikely to be a popular strategy. Searching and not finding
would not be that unexpected but not searching at all seems lazy.
I have a page under construction which uses jQuery
Ouch.

and is fairly massive.

The "do more, write less library" and the results are still "massive"?
When I run it locally under Firefox, everything works fine,
but when I run it on the host site, I frequently run into
difficulties of the following type. I have a $(document).ready()
function

Do you fully understand what JQuery's ready function does? Having read
its code, I suspect that its authors have not fully understood what it
does and so would be amazed if its documentation made a clear and
accurate statement about what can be expected from it. My expectation of
its actual behaviour would be that it would be inconsistent across
browsers, and certainly likely to be subject to timing issues in page
loading if used in a way that was inappropriate for the behaviour it
actually exhibits.
that references variables and elements defined either in other
JS scripts (inline), or in the HTML. Sometimes, but not always,
a reference to one of these variables or elements resolves to
a null pointer, which aborts the execution of my
$(document).ready() function and causes FF to get hung up in the
wrong place.

So your specific issues are on Firefox? JQuery's - ready - function uses
a - DOMContentLoaded - event on the document (assuming the browser
sniffing does not mess up and misidentify the browser, which is always a
possibility). Firefox's documentation may accurately state the full
implications of using that event.
For example, I have a JS variable called 'calimg', which is
supposed to be a string containing the URL of an image file,
and if I look at the source, that is how it is defined, in a
script that is placed before the script containing the $
(document).ready() function. But often, Firebug reports that
the variable 'calimg' is not defined when the
$(document).ready() function runs. What is causing this, and
what can I do about it?

If your implied assertion here is accurate (that you declare a global
variable call - calling - and assign it a value in a global execution
context at a position lexically before a call to - ready - that is also
made in a global execution context) then what you are describing should
be impossible. So your described symptoms and the code details you
describe are mutually contradictory. This is not at all uncommon when
novices ask questions here, and why it can improve the likelihood of a
useful answer if questions are accompanied by a demonstration of the
phenomena being asked about. Though realistically the odds are low that
anyone here would be willing to make the effort to attempt to debug
JQuery code. Sill, you can guarantee that they will not if they cannot
see the code.

Richard.
 
D

David Mark

Do you?!
OK, there are now two people on my list of programmers I would never

Thomas and yourself I presume. If in fact you meant to reply to me,
you needn't bother. I officially remove my name from consideration
for all present and future "Pink Pig" enterprises. I hate pinheads
who post vague "questions" and then cry when they don't get answered.
hire. Any other volunteers, or does somebody want to be informative
rather than snide?

What part of "learn JavaScript" was uninformative. You also got the
very informative advice to avoid jQuery. Hopefully you weren't too
far into your "massive" app to change course. Good luck!
 
P

Pink Pig

Which question? The question you asked, which is effectively ' I have
done something and the outcome is inconsistent', or a question about the
issue that underlies your question?

Cheap shot #1.
That is unlikely to be a popular strategy. Searching and not finding
would not be that unexpected but not searching at all seems lazy.

Cheap shot #2.
The "do more, write less library" and the results are still "massive"?

Cheap shot #3. Is that all you guys are good for?
Do you fully understand what JQuery's ready function does? Having read
its code, I suspect that its authors have not fully understood what it
does and so would be amazed if its documentation made a clear and
accurate statement about what can be expected from it. My expectation of
its actual behaviour would be that it would be inconsistent across
browsers, and certainly likely to be subject to timing issues in page
loading if used in a way that was inappropriate for the behaviour it
actually exhibits.

My expectation, on the other hand, is that there may be bugs in it
that can be worked around one way or another. I do not look down my
nose at people who are trying to clean up the mess created by the
designers of JS -- I wish them well.
So your specific issues are on Firefox? JQuery's - ready - function uses
a - DOMContentLoaded - event on the document (assuming the browser
sniffing does not mess up and misidentify the browser, which is always a
possibility). Firefox's documentation may accurately state the full
implications of using that event.

My specific issue at the moment is in the relationship between FF and
jQuery. I expect that I will have other issues in the future, but I
won't trouble you with them. You haven't yet told me anything I didn't
already know.
If your implied assertion here is accurate (that you declare a global
variable call - calling - and assign it a value in a global execution
context at a position lexically before a call to - ready - that is also
made in a global execution context) then what you are describing should
be impossible. So your described symptoms and the code details you
describe are mutually contradictory. This is not at all uncommon when
novices ask questions here, and why it can improve the likelihood of a
useful answer if questions are accompanied by a demonstration of the
phenomena being asked about.

a) I am not a novice. I was most likely programming before you were
born.

b) I was very careful to describe exactly what was going on, and how
the code was written. I've looked it over, and it's accurate.

c) I did not choose jQuery, and I am not free to just throw it away.
Though realistically the odds are low that
anyone here would be willing to make the effort to attempt to debug
JQuery code. Sill, you can guarantee that they will not if they cannot
see the code.

I gathered as much. I've also noticed that no one has pointed me to a
place where the question might be answered.
 
D

David Mark

Cheap shot #1.

Looks like a reasonable enough question to me.
Cheap shot #2.

No. It does seem lazy.
Cheap shot #3. Is that all you guys are good for?

You really should ask for a refund.
My expectation, on the other hand, is that there may be bugs in it

Fair expectation. There are.
that can be worked around one way or another. I do not look down my
nose at people who are trying to clean up the mess created by the
designers of JS -- I wish them well.

You seem confused.
My specific issue at the moment is in the relationship between FF and
jQuery. I expect that I will have other issues in the future, but I

The relationship is that Mozilla employs the author of jQuery, yet the
library still resorts to browser sniffing to work in FireFox. Seems
like an issue for them at the present. As for your future issues, I
really can't comment.
won't trouble you with them. You haven't yet told me anything I didn't
already know.

Now you are posturing for the one person who actually tried to help.
I imagine that is the last help you will get here. Happily, you've
used an alias, so you can just start over as s pig of a different
color.
a) I am not a novice. I was most likely programming before you were
born.

Whether that is true or not, it was almost certainly not JavaScript.
If your plan was to deploy a "massive" public Web application with
jQuery, then yes, you have made a very typical novice mistake. The
longer you rely on other people's mistakes, the less you will learn.
b) I was very careful to describe exactly what was going on, and how
the code was written. I've looked it over, and it's accurate.

You mean that first post? You forgot to post code or a link to a
sample page. Your ramblings about "null pointers" and "elements
defined either in other JS scripts (inline)", etc. are of little help
(as you were told.)
c) I did not choose jQuery, and I am not free to just throw it away.

Who cares?
I gathered as much. I've also noticed that no one has pointed me to a
place where the question might be answered.

Try Googling "jQuery" or perhaps "jQuery discussion." There's a good
fellow.
 
R

Richard Cornford

Pink said:
Cheap shot #1.

Or an observation that might provide a clue as to how you might get
closer to an getting an answer. Because where you are now is in a hole
and digging as fast as you can.
Cheap shot #2.


Cheap shot #3. Is that all you guys are good for?

That might be a cheep shot. Marketing BS tends to get my back up. On the
other hand "massive" web applications is something that I do know a
thing or two about, and using JQuery in a "massive" (in my terms) web
application would not be a viable proposition. Its unavoidable execution
overheads would reduce the performance of the applications I work on to
such a degree that they would be unsellable.

My expectation, on the other hand, is that there may be bugs
in it that can be worked around one way or another.

A much more probably explanation is that you are doing something wrong
as a result of not understanding javascript and/or web browsers very
well and the best solution is to understand what that is and avoid doing
it. Bugs are not an impossibility but they are also not nearly as common
as people's ignorance resulting in their perception of bugs. Bugs in
javascript implementations' handing of variable instantiation and/or
assignment are very few and far between, and most are in IE so can be
dismissed from this question entirely.
I do not look down my nose at people who are trying to clean
up the mess created by the designers of JS -- I wish them
well.

Who implied that the designers of JS made a mess?

My specific issue at the moment is in the relationship between
FF and jQuery.

How have you eliminated your own JS code from the equation?
I expect that I will have other issues in the future, but I
won't trouble you with them. You haven't yet told me anything
I didn't already know.

You might think so, but you are not behaving as if you did already know
all of the things that I have told you.

a) I am not a novice. I was most likely programming before
you were born.

Maybe you have, but how well do you know javascript and/or browser
scripting?
b) I was very careful to describe exactly what was going on,
and how the code was written. I've looked it over, and it's
accurate.

But you ability to describe what is going on is constrained by your
ability to understand what is going on. There is a contradiction in what
you have described, which at minimum means that something is missing
from that description.
c) I did not choose jQuery, and I am not free to just throw
it away.

Hard luck.
I gathered as much. I've also noticed that no one has pointed me to a
place where the question might be answered.

An answer is something that you can get anywhere (ask the next person
you encounter in that street and you likely will get 'an answer'), but
here is where you stand the best chance of getting the answer, though
only if you manage to ask the question in a form that can be answered.

Richard.
 
H

Hamish Campbell

@Pink

You might try one of the jQuery mailing lists:http://docs.jquery.com/Discussion

If you are on twitter.com you can message @jquery for help :)

Also for fun you can read up on the various personalities here:http://redwing.hutman.net/~mreed/warriorshtm/tirelessrebutter.htm

I hope this helps :D

- JDD

Hey Pink,

The jQuery google group is excellent: http://groups.google.com/group/jquery-en

Plenty of people there (including myself) willing to help out. Try to
post a link to a sample site if possible.

Unfortunately this group can be a little.. old school. I'm pretty sure
that PointedEars et. al. could program JS with an Oscilloscope and a
soldering iron if they really tried. Unfortunately that sword has cut
both ways and they're all but blind to the benefits that jQuery (and
the other hated libraries) bring to real world developers.
 
G

Gregor Kofler

Hamish Campbell meinte:
Hey Pink,

The jQuery google group is excellent:
http://groups.google.com/group/jquery-en

Plenty of people there (including myself) willing to help out. Try to
post a link to a sample site if possible.

From the information given by the OP, they were equally helpless.
Unfortunately this group can be a little.. old school.

No. It's just that this group is about JavaScript (and its other brand
names) and not about some libraries written in JS. Just as PHP NGs are
about PHP and not some third party applications written in PHP. And just
as C/C++ NGs are not dealing with the problems of applications written
in these languages. You get the idea?
they're all but blind to the benefits that jQuery (and
the other hated libraries) bring to real world developers.

Makes one wonder why all those problems (I suppose I should say
"questions") of such "real world developers" come from...

Gregor
 
A

Aaron Gray

Thomas 'PointedEars' Lahn said:
Pink said:
Thomas said:
Pink Pig wrote:
[...] But often, Firebug reports that the variable 'calimg' is not
defined when the $(document).ready() function runs. What is causing
this,
and what can I do about it?
Get a minimum clue and don't rely on junk like jQuery.

<http://jibbering.com/faq/>
[...]

This is really not a helpful response. You might at least point me to
the appropriate section of this massive document.

Try the section about how to post properly; it will lead to everything
else.

Thomas, You are turning into a bit of a troll. Could you say the same
substance but in a more polite fashon please; as its degrading the list.

Yeah, I never liked jQuery from the start, bumping into $("yyy"). when
reading code was not a very nice experience.

There's another library I have came accross that seems to do the same as
jQuery but seems alot lighterweight and have not heard it mentioned on clj.

http://www.domassistant.com/

Have not used it, but it has four figure version numbers and is up to
2.7.1.1 so it _may_ be a good library.

Anyone checked it out ?

Aaron
 
A

Aaron Gray

Pink Pig said:
(I don't know if this question has been asked and answered many times,
since I just joined this group and haven't attempted to search the
archives.)

I have a page under construction which uses jQuery and is fairly
massive. When I run it locally under Firefox, everything works fine,
but when I run it on the host site, I frequently run into difficulties
of the following type. I have a $(document).ready() function that
references variables and elements defined either in other JS scripts
(inline), or in the HTML. Sometimes, but not always, a reference to
one of these variables or elements resolves to a null pointer, which
aborts the execution of my $(document).ready() function and causes FF
to get hung up in the wrong place. For example, I have a JS variable
called 'calimg', which is supposed to be a string containing the URL
of an image file, and if I look at the source, that is how it is
defined, in a script that is placed before the script containing the $
(document).ready() function. But often, Firebug reports that the
variable 'calimg' is not defined when the $(document).ready() function
runs. What is causing this, and what can I do about it?

Yeah, sorry but you have to realize that if everyone is reading your
question thet is X amount of time times Y readers, these whole threads are a
waste of time and should be avoided, best for both sides not to start them
in the first place.

As they say a library is no substitute for knowing whats going on with "bare
metal javascript".

If there are issues with jQuery then take them to one of the jQuery
disscussion lists :-

http://docs.jquery.com/Discussion

comp.lang.javascript is really for Javascript language issues, this is not
alt.lang.javascript and maybe there should really be one.

Aaron
 
A

Aaron Gray

Unfortunately this group can be a little.. old school. I'm pretty sure

Look at the UseNet groups title "comp.lang.javascript" this sort of thing
would not be tollerated on comp.lang.c or c++. Maybe we need a
comp.lang.javascript.misc or alt.javascript group for this sort of thing ?

Regards,

Aaron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top