[jQuery] Re: function not defined
I tried again with this reference, and now with settings.originalCall.myFunction() I received that the function is not a function :-\
[jQuery] Re: $ is not defined error
Glad to help, Betty. But I think I may have been confused too. (Actually, I *know* I'm confused at this point.) Here's a post from Dave Methvin that explains some of the moving/cloning behavior: http://groups.google.com/group/jquery-en/msg/85833f44e69e8c6c I'm not sure from Dave's description just what happens in the case we were discussing. Anyway, if you want to play it safe, and if you want to be able to copy the same element multiple times, there are a couple of ways to do it. One would be to clone and insert it - and I would change the element ID while you're at it since you shouldn't have two elements with the same ID. Going back to your original code, you might do something like: var idnum = 0; // put this line in the global scope $('#respond') .clone() .attr({ id: 'respond' + (++idnum) }) .insertAfter($('div.comment')); Or, instead of cloning an element at all, you could create a fresh copy from HTML text in your JavaScript code each time. Your #respond DIV is fairly lengthy, so you may not want to do that here, but it's a good way to do simpler elements. -Mike From: Betty Thank you, Mike. You're so patient and helpful! Apparently I didn't understand insertAfter() well enough. I thought it would move the object, not duplicate the object. Is there a function in jQuery that simply moves an object? Or, if I remove() the object, do I need to add() it again if I want to use it some time later? Again, thank you very much! On Jan 3, 1:28 pm, Michael Geary m...@mg.to wrote: Do you notice that the page also blanks out when you get the error? Why is that? Try this: Open your page and open the Firebug panel. Now click the button that provokes the error. Then click on the filename in the Firebug error message (my.etc.js line 68). You should get the source code for your jQuery.ajax function. The error is happening in the beforeSend callback. Set a breakpoint on the line *before* the error, line 67, by clicking on the line number. Now click the Back button, then click the button that provokes the error again. It should stop on line 67. The page still looks OK. Click in the yellow New watch expression bar and type $ and the Enter key. You should get a function listed in the watch window, and if you expand it, it will be seen to be the jQuery constructor. Now step over the code in line 67. (On Windows, the F10 key will do it. Or on any platform, use the Step Over icon on the right side of the Firebug panel.) Boom. The page blanks out, and the $ in the watch window turns into a reference error. Clearly, the code on page 67 has trashed your document. Why? Well, the code in line 67 is: $('#respond').insertAfter($(div.comment)); That's taking an existing DOM element and inserting it in a second place in the DOM. This is a Very Bad Thing. A DOM node can't be in two places at once. Try repeating the experiment (you may need to restart Firefox first if it's badly trashed), and when you get to line 67, instead of stepping over it, enter either of these two statements in the Firebug console: $('#respond').remove().insertAfter($(div.comment)); Now you'll find that the document is not trashed; either statement executes successfully. This is because the statements avoid having the same node appear in two places. The first one removes the node from its current location before inserting it; the second one clones the node. I'm not sure which of these is what you want (if indeed either is), but this should help point you toward a solution. Note that the second version of the code: $('#respond').clone().insertAfter($(div.comment)); leaves the document in a somewhat invalid state, because there are now two elements with the same ID (respond). But that's not a document-trashing error. It's not recommended, but browsers generally let you get away with it. -Mike From: Betty I get this error in the Firefox error console: $ is not defined. it points me to line $(div#respondh3).html(Reply to); I'm sure I've set jQuery properly because it works fine in other browsers and the other jQuery effects I use can work in Firefox. Only this part does not work. Actually, it works on my local test computer, but if I upload the same file to the server, this part gets this error. I can't understand why. If you need an example, it's a href=http://myfairland.net/mizong/ #commentshttp://myfairland.net/mizong/#comments/a. The site is in Chinese. If you put the mouse on the comment part and click the button that appears, with the Chinese word that means reply, you can get the error in Firefox. This error really frustrates me. If you can help me, I'll appreciate you very much! Many thanks!
[jQuery] Re: $ is not defined error
I checked the jQuery official documents and it says that starting with 1.2.2 $(#foo).remove().appendTo(#bar); should be written as $(#foo).appendTo(#bar); (http://docs.jquery.com/Manipulation/remove#expr) I assume appendTo() and insertAfter() follow the same rules. It seems like they do move the object instead of copy it? I'm confused now... On Jan 3, 3:31 pm, Betty xlu.2...@gmail.com wrote: Thank you, Mike. You're so patient and helpful! Apparently I didn't understand insertAfter() well enough. I thought it would move the object, not duplicate the object. Is there a function in jQuery that simply moves an object? Or, if I remove() the object, do I need to add() it again if I want to use it some time later? Again, thank you very much! On Jan 3, 1:28 pm, Michael Geary m...@mg.to wrote: Do you notice that the page also blanks out when you get the error? Why is that? Try this: Open your page and open the Firebug panel. Now click the button that provokes the error. Then click on the filename in the Firebug error message (my.etc.js line 68). You should get the source code for your jQuery.ajax function. The error is happening in the beforeSend callback. Set a breakpoint on the line *before* the error, line 67, by clicking on the line number. Now click the Back button, then click the button that provokes the error again. It should stop on line 67. The page still looks OK. Click in the yellow New watch expression bar and type $ and the Enter key. You should get a function listed in the watch window, and if you expand it, it will be seen to be the jQuery constructor. Now step over the code in line 67. (On Windows, the F10 key will do it. Or on any platform, use the Step Over icon on the right side of the Firebug panel.) Boom. The page blanks out, and the $ in the watch window turns into a reference error. Clearly, the code on page 67 has trashed your document. Why? Well, the code in line 67 is: $('#respond').insertAfter($(div.comment)); That's taking an existing DOM element and inserting it in a second place in the DOM. This is a Very Bad Thing. A DOM node can't be in two places at once. Try repeating the experiment (you may need to restart Firefox first if it's badly trashed), and when you get to line 67, instead of stepping over it, enter either of these two statements in the Firebug console: $('#respond').remove().insertAfter($(div.comment)); Now you'll find that the document is not trashed; either statement executes successfully. This is because the statements avoid having the same node appear in two places. The first one removes the node from its current location before inserting it; the second one clones the node. I'm not sure which of these is what you want (if indeed either is), but this should help point you toward a solution. Note that the second version of the code: $('#respond').clone().insertAfter($(div.comment)); leaves the document in a somewhat invalid state, because there are now two elements with the same ID (respond). But that's not a document-trashing error. It's not recommended, but browsers generally let you get away with it. -Mike From: Betty I get this error in the Firefox error console: $ is not defined. it points me to line $(div#respondh3).html(Reply to); I'm sure I've set jQuery properly because it works fine in other browsers and the other jQuery effects I use can work in Firefox. Only this part does not work. Actually, it works on my local test computer, but if I upload the same file to the server, this part gets this error. I can't understand why. If you need an example, it's a href=http://myfairland.net/mizong/ #commentshttp://myfairland.net/mizong/#comments/a. The site is in Chinese. If you put the mouse on the comment part and click the button that appears, with the Chinese word that means reply, you can get the error in Firefox. This error really frustrates me. If you can help me, I'll appreciate you very much! Many thanks!
[jQuery] Re: $ is not defined error
Thank you, Mike. I don't whether I can change the #respond id. Because it contains the comment form, it may not work properly if the id is changed. Maybe I have made it too complicated. What I want is simply this (I'm sure you've seen it on other sites, or perhaps you've even done that yourself): a comment list, with the comment form at the end If the user clicks the reply button at a comment node, the comment form will be placed under that comment node. If the user clicks at another comment node, the comment form will be moved to that other node. If the user clicks cancel, the comment form will be put back to the bottom. On Jan 3, 4:07 pm, Michael Geary m...@mg.to wrote: Glad to help, Betty. But I think I may have been confused too. (Actually, I *know* I'm confused at this point.) Here's a post from Dave Methvin that explains some of the moving/cloning behavior: http://groups.google.com/group/jquery-en/msg/85833f44e69e8c6c I'm not sure from Dave's description just what happens in the case we were discussing. Anyway, if you want to play it safe, and if you want to be able to copy the same element multiple times, there are a couple of ways to do it. One would be to clone and insert it - and I would change the element ID while you're at it since you shouldn't have two elements with the same ID. Going back to your original code, you might do something like: var idnum = 0; // put this line in the global scope $('#respond') .clone() .attr({ id: 'respond' + (++idnum) }) .insertAfter($('div.comment')); Or, instead of cloning an element at all, you could create a fresh copy from HTML text in your JavaScript code each time. Your #respond DIV is fairly lengthy, so you may not want to do that here, but it's a good way to do simpler elements. -Mike From: Betty Thank you, Mike. You're so patient and helpful! Apparently I didn't understand insertAfter() well enough. I thought it would move the object, not duplicate the object. Is there a function in jQuery that simply moves an object? Or, if I remove() the object, do I need to add() it again if I want to use it some time later? Again, thank you very much! On Jan 3, 1:28 pm, Michael Geary m...@mg.to wrote: Do you notice that the page also blanks out when you get the error? Why is that? Try this: Open your page and open the Firebug panel. Now click the button that provokes the error. Then click on the filename in the Firebug error message (my.etc.js line 68). You should get the source code for your jQuery.ajax function. The error is happening in the beforeSend callback. Set a breakpoint on the line *before* the error, line 67, by clicking on the line number. Now click the Back button, then click the button that provokes the error again. It should stop on line 67. The page still looks OK. Click in the yellow New watch expression bar and type $ and the Enter key. You should get a function listed in the watch window, and if you expand it, it will be seen to be the jQuery constructor. Now step over the code in line 67. (On Windows, the F10 key will do it. Or on any platform, use the Step Over icon on the right side of the Firebug panel.) Boom. The page blanks out, and the $ in the watch window turns into a reference error. Clearly, the code on page 67 has trashed your document. Why? Well, the code in line 67 is: $('#respond').insertAfter($(div.comment)); That's taking an existing DOM element and inserting it in a second place in the DOM. This is a Very Bad Thing. A DOM node can't be in two places at once. Try repeating the experiment (you may need to restart Firefox first if it's badly trashed), and when you get to line 67, instead of stepping over it, enter either of these two statements in the Firebug console: $('#respond').remove().insertAfter($(div.comment)); Now you'll find that the document is not trashed; either statement executes successfully. This is because the statements avoid having the same node appear in two places. The first one removes the node from its current location before inserting it; the second one clones the node. I'm not sure which of these is what you want (if indeed either is), but this should help point you toward a solution. Note that the second version of the code: $('#respond').clone().insertAfter($(div.comment)); leaves the document in a somewhat invalid state, because there are now two elements with the same ID (respond). But that's not a document-trashing error. It's not recommended, but browsers generally let you get away with it. -Mike From: Betty I get this error in the Firefox error console: $ is not defined. it points me to line $(div#respondh3).html(Reply to); I'm sure I've set jQuery properly because it works fine in other browsers and
[jQuery] Re: $ is not defined error
Aha! I figured it out. It wasn't the cloning vs. moving thing I was talking about at all. Sorry - I was just mixed up about that. Here's the real problem. Take a look at the content of your respond DIV. At the end of it you have a script element that does a document.write() call. One of the things that .insertAfter() and the other similar jQuery operations do is *run all the scripts* in the elements they are inserting. So, when you try to insert a new copy of this DIV, jQuery runs that script. But you can't - or shouldn't - call document.write() after the document has already been closed. You can only call document.write() during the initial page load, not when you are running JavaScript code later on when the user interacts with the page. What happens when you do this is that the browser re-opens the document, which clears out all of its existing content! That's why the document is blanking, and why $ is disappearing. I'm not sure what that script element is for, but as a quick test, if you remove it (and just for good measure, remove the noscript right above it too), I'm sure the immediate problem will go away. -Mike From: Betty I checked the jQuery official documents and it says that starting with 1.2.2 $(#foo).remove().appendTo(#bar); should be written as $(#foo).appendTo(#bar); (http://docs.jquery.com/Manipulation/remove#expr) I assume appendTo() and insertAfter() follow the same rules. It seems like they do move the object instead of copy it? I'm confused now... On Jan 3, 3:31 pm, Betty xlu.2...@gmail.com wrote: Thank you, Mike. You're so patient and helpful! Apparently I didn't understand insertAfter() well enough. I thought it would move the object, not duplicate the object. Is there a function in jQuery that simply moves an object? Or, if I remove() the object, do I need to add() it again if I want to use it some time later? Again, thank you very much! On Jan 3, 1:28 pm, Michael Geary m...@mg.to wrote: Do you notice that the page also blanks out when you get the error? Why is that? Try this: Open your page and open the Firebug panel. Now click the button that provokes the error. Then click on the filename in the Firebug error message (my.etc.js line 68). You should get the source code for your jQuery.ajax function. The error is happening in the beforeSend callback. Set a breakpoint on the line *before* the error, line 67, by clicking on the line number. Now click the Back button, then click the button that provokes the error again. It should stop on line 67. The page still looks OK. Click in the yellow New watch expression bar and type $ and the Enter key. You should get a function listed in the watch window, and if you expand it, it will be seen to be the jQuery constructor. Now step over the code in line 67. (On Windows, the F10 key will do it. Or on any platform, use the Step Over icon on the right side of the Firebug panel.) Boom. The page blanks out, and the $ in the watch window turns into a reference error. Clearly, the code on page 67 has trashed your document. Why? Well, the code in line 67 is: $('#respond').insertAfter($(div.comment)); That's taking an existing DOM element and inserting it in a second place in the DOM. This is a Very Bad Thing. A DOM node can't be in two places at once. Try repeating the experiment (you may need to restart Firefox first if it's badly trashed), and when you get to line 67, instead of stepping over it, enter either of these two statements in the Firebug console: $('#respond').remove().insertAfter($(div.comment)); Now you'll find that the document is not trashed; either statement executes successfully. This is because the statements avoid having the same node appear in two places. The first one removes the node from its current location before inserting it; the second one clones the node. I'm not sure which of these is what you want (if indeed either is), but this should help point you toward a solution. Note that the second version of the code: $('#respond').clone().insertAfter($(div.comment)); leaves the document in a somewhat invalid state, because there are now two elements with the same ID (respond). But that's not a document-trashing error. It's not recommended, but browsers generally let you get away with it. -Mike From: Betty I get this error in the Firefox error console: $ is not defined. it points me to line $(div#respondh3).html(Reply to); I'm sure I've set jQuery properly because it works fine in other browsers and the other jQuery effects I use can work in Firefox. Only this part does not work. Actually, it works on my local test computer, but if I upload the same file to the server, this part gets
[jQuery] Re: $ is not defined error
OMG! I didn't put that noscript thing there. I don't know why it's there. I'll check if my site is hacked... You are like my savior. Thank you so much! On Jan 3, 4:38 pm, Michael Geary m...@mg.to wrote: Aha! I figured it out. It wasn't the cloning vs. moving thing I was talking about at all. Sorry - I was just mixed up about that. Here's the real problem. Take a look at the content of your respond DIV. At the end of it you have a script element that does a document.write() call. One of the things that .insertAfter() and the other similar jQuery operations do is *run all the scripts* in the elements they are inserting. So, when you try to insert a new copy of this DIV, jQuery runs that script. But you can't - or shouldn't - call document.write() after the document has already been closed. You can only call document.write() during the initial page load, not when you are running JavaScript code later on when the user interacts with the page. What happens when you do this is that the browser re-opens the document, which clears out all of its existing content! That's why the document is blanking, and why $ is disappearing. I'm not sure what that script element is for, but as a quick test, if you remove it (and just for good measure, remove the noscript right above it too), I'm sure the immediate problem will go away. -Mike From: Betty I checked the jQuery official documents and it says that starting with 1.2.2 $(#foo).remove().appendTo(#bar); should be written as $(#foo).appendTo(#bar); (http://docs.jquery.com/Manipulation/remove#expr) I assume appendTo() and insertAfter() follow the same rules. It seems like they do move the object instead of copy it? I'm confused now... On Jan 3, 3:31 pm, Betty xlu.2...@gmail.com wrote: Thank you, Mike. You're so patient and helpful! Apparently I didn't understand insertAfter() well enough. I thought it would move the object, not duplicate the object. Is there a function in jQuery that simply moves an object? Or, if I remove() the object, do I need to add() it again if I want to use it some time later? Again, thank you very much! On Jan 3, 1:28 pm, Michael Geary m...@mg.to wrote: Do you notice that the page also blanks out when you get the error? Why is that? Try this: Open your page and open the Firebug panel. Now click the button that provokes the error. Then click on the filename in the Firebug error message (my.etc.js line 68). You should get the source code for your jQuery.ajax function. The error is happening in the beforeSend callback. Set a breakpoint on the line *before* the error, line 67, by clicking on the line number. Now click the Back button, then click the button that provokes the error again. It should stop on line 67. The page still looks OK. Click in the yellow New watch expression bar and type $ and the Enter key. You should get a function listed in the watch window, and if you expand it, it will be seen to be the jQuery constructor. Now step over the code in line 67. (On Windows, the F10 key will do it. Or on any platform, use the Step Over icon on the right side of the Firebug panel.) Boom. The page blanks out, and the $ in the watch window turns into a reference error. Clearly, the code on page 67 has trashed your document. Why? Well, the code in line 67 is: $('#respond').insertAfter($(div.comment)); That's taking an existing DOM element and inserting it in a second place in the DOM. This is a Very Bad Thing. A DOM node can't be in two places at once. Try repeating the experiment (you may need to restart Firefox first if it's badly trashed), and when you get to line 67, instead of stepping over it, enter either of these two statements in the Firebug console: $('#respond').remove().insertAfter($(div.comment)); Now you'll find that the document is not trashed; either statement executes successfully. This is because the statements avoid having the same node appear in two places. The first one removes the node from its current location before inserting it; the second one clones the node. I'm not sure which of these is what you want (if indeed either is), but this should help point you toward a solution. Note that the second version of the code: $('#respond').clone().insertAfter($(div.comment)); leaves the document in a somewhat invalid state, because there are now two elements with the same ID (respond). But that's not a document-trashing error. It's not recommended, but browsers generally let you get away with it. -Mike From: Betty I get this error in the Firefox error console: $ is not defined. it points me to line $(div#respondh3).html(Reply to); I'm sure I've set jQuery properly because it works fine
[jQuery] Re: $ is not defined error
Oh, I know why there is such a script element. It's one of the wordpress plugins I use. -.- Strangely, it only conflicts with Firefox. I don't know how to thank you, Mike. It's so kind and patient of you. You are the best person I've met this year. :) On Jan 3, 6:38 pm, Betty xlu.2...@gmail.com wrote: OMG! I didn't put that noscript thing there. I don't know why it's there. I'll check if my site is hacked... You are like my savior. Thank you so much! On Jan 3, 4:38 pm, Michael Geary m...@mg.to wrote: Aha! I figured it out. It wasn't the cloning vs. moving thing I was talking about at all. Sorry - I was just mixed up about that. Here's the real problem. Take a look at the content of your respond DIV. At the end of it you have a script element that does a document.write() call. One of the things that .insertAfter() and the other similar jQuery operations do is *run all the scripts* in the elements they are inserting. So, when you try to insert a new copy of this DIV, jQuery runs that script. But you can't - or shouldn't - call document.write() after the document has already been closed. You can only call document.write() during the initial page load, not when you are running JavaScript code later on when the user interacts with the page. What happens when you do this is that the browser re-opens the document, which clears out all of its existing content! That's why the document is blanking, and why $ is disappearing. I'm not sure what that script element is for, but as a quick test, if you remove it (and just for good measure, remove the noscript right above it too), I'm sure the immediate problem will go away. -Mike From: Betty I checked the jQuery official documents and it says that starting with 1.2.2 $(#foo).remove().appendTo(#bar); should be written as $(#foo).appendTo(#bar); (http://docs.jquery.com/Manipulation/remove#expr) I assume appendTo() and insertAfter() follow the same rules. It seems like they do move the object instead of copy it? I'm confused now... On Jan 3, 3:31 pm, Betty xlu.2...@gmail.com wrote: Thank you, Mike. You're so patient and helpful! Apparently I didn't understand insertAfter() well enough. I thought it would move the object, not duplicate the object. Is there a function in jQuery that simply moves an object? Or, if I remove() the object, do I need to add() it again if I want to use it some time later? Again, thank you very much! On Jan 3, 1:28 pm, Michael Geary m...@mg.to wrote: Do you notice that the page also blanks out when you get the error? Why is that? Try this: Open your page and open the Firebug panel. Now click the button that provokes the error. Then click on the filename in the Firebug error message (my.etc.js line 68). You should get the source code for your jQuery.ajax function. The error is happening in the beforeSend callback. Set a breakpoint on the line *before* the error, line 67, by clicking on the line number. Now click the Back button, then click the button that provokes the error again. It should stop on line 67. The page still looks OK. Click in the yellow New watch expression bar and type $ and the Enter key. You should get a function listed in the watch window, and if you expand it, it will be seen to be the jQuery constructor. Now step over the code in line 67. (On Windows, the F10 key will do it. Or on any platform, use the Step Over icon on the right side of the Firebug panel.) Boom. The page blanks out, and the $ in the watch window turns into a reference error. Clearly, the code on page 67 has trashed your document. Why? Well, the code in line 67 is: $('#respond').insertAfter($(div.comment)); That's taking an existing DOM element and inserting it in a second place in the DOM. This is a Very Bad Thing. A DOM node can't be in two places at once. Try repeating the experiment (you may need to restart Firefox first if it's badly trashed), and when you get to line 67, instead of stepping over it, enter either of these two statements in the Firebug console: $('#respond').remove().insertAfter($(div.comment)); Now you'll find that the document is not trashed; either statement executes successfully. This is because the statements avoid having the same node appear in two places. The first one removes the node from its current location before inserting it; the second one clones the node. I'm not sure which of these is what you want (if indeed either is), but this should help point you toward a solution. Note that the second version of the code: $('#respond').clone().insertAfter($(div.comment)); leaves the document in a somewhat invalid state, because
[jQuery] Re: $ is not defined error
Do you notice that the page also blanks out when you get the error? Why is that? Try this: Open your page and open the Firebug panel. Now click the button that provokes the error. Then click on the filename in the Firebug error message (my.etc.js line 68). You should get the source code for your jQuery.ajax function. The error is happening in the beforeSend callback. Set a breakpoint on the line *before* the error, line 67, by clicking on the line number. Now click the Back button, then click the button that provokes the error again. It should stop on line 67. The page still looks OK. Click in the yellow New watch expression bar and type $ and the Enter key. You should get a function listed in the watch window, and if you expand it, it will be seen to be the jQuery constructor. Now step over the code in line 67. (On Windows, the F10 key will do it. Or on any platform, use the Step Over icon on the right side of the Firebug panel.) Boom. The page blanks out, and the $ in the watch window turns into a reference error. Clearly, the code on page 67 has trashed your document. Why? Well, the code in line 67 is: $('#respond').insertAfter($(div.comment)); That's taking an existing DOM element and inserting it in a second place in the DOM. This is a Very Bad Thing. A DOM node can't be in two places at once. Try repeating the experiment (you may need to restart Firefox first if it's badly trashed), and when you get to line 67, instead of stepping over it, enter either of these two statements in the Firebug console: $('#respond').remove().insertAfter($(div.comment)); Now you'll find that the document is not trashed; either statement executes successfully. This is because the statements avoid having the same node appear in two places. The first one removes the node from its current location before inserting it; the second one clones the node. I'm not sure which of these is what you want (if indeed either is), but this should help point you toward a solution. Note that the second version of the code: $('#respond').clone().insertAfter($(div.comment)); leaves the document in a somewhat invalid state, because there are now two elements with the same ID (respond). But that's not a document-trashing error. It's not recommended, but browsers generally let you get away with it. -Mike From: Betty I get this error in the Firefox error console: $ is not defined. it points me to line $(div#respondh3).html(Reply to); I'm sure I've set jQuery properly because it works fine in other browsers and the other jQuery effects I use can work in Firefox. Only this part does not work. Actually, it works on my local test computer, but if I upload the same file to the server, this part gets this error. I can't understand why. If you need an example, it's a href=http://myfairland.net/mizong/ #commentshttp://myfairland.net/mizong/#comments/a. The site is in Chinese. If you put the mouse on the comment part and click the button that appears, with the Chinese word that means reply, you can get the error in Firefox. This error really frustrates me. If you can help me, I'll appreciate you very much! Many thanks!
[jQuery] Re: $ is not defined error
Thank you, Mike. You're so patient and helpful! Apparently I didn't understand insertAfter() well enough. I thought it would move the object, not duplicate the object. Is there a function in jQuery that simply moves an object? Or, if I remove() the object, do I need to add() it again if I want to use it some time later? Again, thank you very much! On Jan 3, 1:28 pm, Michael Geary m...@mg.to wrote: Do you notice that the page also blanks out when you get the error? Why is that? Try this: Open your page and open the Firebug panel. Now click the button that provokes the error. Then click on the filename in the Firebug error message (my.etc.js line 68). You should get the source code for your jQuery.ajax function. The error is happening in the beforeSend callback. Set a breakpoint on the line *before* the error, line 67, by clicking on the line number. Now click the Back button, then click the button that provokes the error again. It should stop on line 67. The page still looks OK. Click in the yellow New watch expression bar and type $ and the Enter key. You should get a function listed in the watch window, and if you expand it, it will be seen to be the jQuery constructor. Now step over the code in line 67. (On Windows, the F10 key will do it. Or on any platform, use the Step Over icon on the right side of the Firebug panel.) Boom. The page blanks out, and the $ in the watch window turns into a reference error. Clearly, the code on page 67 has trashed your document. Why? Well, the code in line 67 is: $('#respond').insertAfter($(div.comment)); That's taking an existing DOM element and inserting it in a second place in the DOM. This is a Very Bad Thing. A DOM node can't be in two places at once. Try repeating the experiment (you may need to restart Firefox first if it's badly trashed), and when you get to line 67, instead of stepping over it, enter either of these two statements in the Firebug console: $('#respond').remove().insertAfter($(div.comment)); Now you'll find that the document is not trashed; either statement executes successfully. This is because the statements avoid having the same node appear in two places. The first one removes the node from its current location before inserting it; the second one clones the node. I'm not sure which of these is what you want (if indeed either is), but this should help point you toward a solution. Note that the second version of the code: $('#respond').clone().insertAfter($(div.comment)); leaves the document in a somewhat invalid state, because there are now two elements with the same ID (respond). But that's not a document-trashing error. It's not recommended, but browsers generally let you get away with it. -Mike From: Betty I get this error in the Firefox error console: $ is not defined. it points me to line $(div#respondh3).html(Reply to); I'm sure I've set jQuery properly because it works fine in other browsers and the other jQuery effects I use can work in Firefox. Only this part does not work. Actually, it works on my local test computer, but if I upload the same file to the server, this part gets this error. I can't understand why. If you need an example, it's a href=http://myfairland.net/mizong/ #commentshttp://myfairland.net/mizong/#comments/a. The site is in Chinese. If you put the mouse on the comment part and click the button that appears, with the Chinese word that means reply, you can get the error in Firefox. This error really frustrates me. If you can help me, I'll appreciate you very much! Many thanks!
[jQuery] Re: error $ not defined
You got it. here you go. the file is located in c:/inetpub/wwwroot/domain and the jquery file is located in c:/inetpub/wwwroot/domain/js/jquery-1.2.6.min.js html head script type=text/javascript src=js/jquery-1.2.6.min.js/script script type=text/javascript $(function(){ $(a).click(function(event){ event.preventDefault(); // prevent the default action - which in the case of a means 'don't go there' $(this).hide(slow); //Hide the element - slowly :) }); $(a).addClass(test); // adds the class 'test' to ALL a links $(#orderedlist).addClass(red); // Add the class 'red' to the element named orederedlist $(#orderedlist li).addClass(blue); //Add the class 'blue' to any list item immediately under the id orderedlist $(#orderedlist li ul li).addClass(green); $(#orderedlist li ul li:last).addClass(purple); }); /script style type=text/css a.test { font-weight: bold; } .red {border: 1px solid red;} .blue {color:blue;} .green {color:green;} .purple {color:#663366;} /style /head body pa href=# class=clickmejQuery/a a href=Link/a/p ul id=orderedlist liHello ul liWorld/li /ul /li liThisis my ul liFriend/li liSam/li /ul /li /ul /body /html
[jQuery] Re: error $ not defined
Please show us your actual .html file. Otherwise it's anyone's guess what might be wrong. -Mike -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Chris Sent: Tuesday, September 02, 2008 4:40 PM To: jQuery (English) Subject: [jQuery] Re: error $ not defined I found this to be the trouble I am having - however it is localized to only my development server (localhost in this case) Using firebug I have confirmed that the jquery.js script is not being found when I load the page via localhost/domain/jquerytest.htm. However all the other js files are loaded correctly. Also on the server the jquery.js file is located and served correctly. Anyone have any ideas what I could be missing on my local machine that would cause this one js file to not be found? thanks, Chris On Aug 20, 9:24 pm, Karl Swedberg [EMAIL PROTECTED] wrote: This error appears when the core jQuery fie is not included, either because there is no script tag with a src attribute pointing to it or because the src attribute is pointing to the wrong place. It can also appear when you include scripts that use jQuery before you include the core jQuery file. Since it looks like you have a reference to it, and the reference is coming before any references to scripts that use it, my only other guess is that it's pointing to an incorrect location. Try opening the Script tab in Firebug and examining the jquery.js script. If it shows you some html instead of javascript, then you're getting a 404. Another way you could troubleshoot this is to paste this next line in and use it instead of your script type=text/javascript src=js/ jquery.js/script: script src=http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js type=text/javascript/script If that one works, then most likely your other one is getting a 404. Hope that helps. --Karl Karl Swedbergwww.englishrules.comwww.learningjquery.com On Aug 20, 2008, at 7:13 PM, larksys wrote: I'm trying to apply what I know so far to my CF page and an autosuggest input field. The very first line of javascript give an error; $ not defined $(document).ready(function(){ The java script files are included ( I checked that) The css files are included (I checked that) link rel=stylesheet type=text/css href=js/ jquery.autocomplete.css / script type=text/javascript src=js/jquery.js/script script type=text/javascript src=js/jquery.autocomplete.js/ script And this script; script type=text/javascript $(document).ready(function(){ $('#suggest1').html(' nbsp;'); $(#idm).change( function() { var formval = { idm:$(this) .val()}; $.ajax({ type: POST, url: panels/panelCandidates_1_db.cfm, dataType: json, data: formval, success: function(response){ $('#suggest1').fadeIn(2000).append(response.MAIN_DISH); } }); }); }); /script And this html; cfinput name=NewCandidate type=text / span id=suggest1/span I'll be /1#%/1 if I can figure out how the input field is triggering anything.
[jQuery] Re: error $ not defined
I found this to be the trouble I am having - however it is localized to only my development server (localhost in this case) Using firebug I have confirmed that the jquery.js script is not being found when I load the page via localhost/domain/jquerytest.htm. However all the other js files are loaded correctly. Also on the server the jquery.js file is located and served correctly. Anyone have any ideas what I could be missing on my local machine that would cause this one js file to not be found? thanks, Chris On Aug 20, 9:24 pm, Karl Swedberg [EMAIL PROTECTED] wrote: This error appears when the core jQuery fie is not included, either because there is no script tag with a src attribute pointing to it or because the src attribute is pointing to the wrong place. It can also appear when you include scripts that use jQuery before you include the core jQuery file. Since it looks like you have a reference to it, and the reference is coming before any references to scripts that use it, my only other guess is that it's pointing to an incorrect location. Try opening the Script tab in Firebug and examining the jquery.js script. If it shows you some html instead of javascript, then you're getting a 404. Another way you could troubleshoot this is to paste this next line in and use it instead of your script type=text/javascript src=js/ jquery.js/script: script src=http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js type=text/javascript/script If that one works, then most likely your other one is getting a 404. Hope that helps. --Karl Karl Swedbergwww.englishrules.comwww.learningjquery.com On Aug 20, 2008, at 7:13 PM, larksys wrote: I'm trying to apply what I know so far to my CF page and an autosuggest input field. The very first line of javascript give an error; $ not defined $(document).ready(function(){ The java script files are included ( I checked that) The css files are included (I checked that) link rel=stylesheet type=text/css href=js/ jquery.autocomplete.css / script type=text/javascript src=js/jquery.js/script script type=text/javascript src=js/jquery.autocomplete.js/ script And this script; script type=text/javascript $(document).ready(function(){ $('#suggest1').html(' nbsp;'); $(#idm).change( function() { var formval = { idm:$(this) .val()}; $.ajax({ type: POST, url: panels/panelCandidates_1_db.cfm, dataType: json, data: formval, success: function(response){ $('#suggest1').fadeIn(2000).append(response.MAIN_DISH); } }); }); }); /script And this html; cfinput name=NewCandidate type=text / span id=suggest1/span I'll be /1#%/1 if I can figure out how the input field is triggering anything.
[jQuery] Re: error $ not defined
This error appears when the core jQuery fie is not included, either because there is no script tag with a src attribute pointing to it or because the src attribute is pointing to the wrong place. It can also appear when you include scripts that use jQuery before you include the core jQuery file. Since it looks like you have a reference to it, and the reference is coming before any references to scripts that use it, my only other guess is that it's pointing to an incorrect location. Try opening the Script tab in Firebug and examining the jquery.js script. If it shows you some html instead of javascript, then you're getting a 404. Another way you could troubleshoot this is to paste this next line in and use it instead of your script type=text/javascript src=js/ jquery.js/script: script src=http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js type=text/javascript/script If that one works, then most likely your other one is getting a 404. Hope that helps. --Karl Karl Swedberg www.englishrules.com www.learningjquery.com On Aug 20, 2008, at 7:13 PM, larksys wrote: I'm trying to apply what I know so far to my CF page and an autosuggest input field. The very first line of javascript give an error; $ not defined $(document).ready(function(){ The java script files are included ( I checked that) The css files are included (I checked that) link rel=stylesheet type=text/css href=js/ jquery.autocomplete.css / script type=text/javascript src=js/jquery.js/script script type=text/javascript src=js/jquery.autocomplete.js/ script And this script; script type=text/javascript $(document).ready(function(){ $('#suggest1').html(' nbsp;'); $(#idm).change( function() { var formval = { idm:$(this) .val()}; $.ajax({ type: POST, url: panels/panelCandidates_1_db.cfm, dataType: json, data: formval, success: function(response){ $('#suggest1').fadeIn(2000).append(response.MAIN_DISH); } }); }); }); /script And this html; cfinput name=NewCandidate type=text / span id=suggest1/span I'll be /1#%/1 if I can figure out how the input field is triggering anything.
[jQuery] Re: error $ not defined
I finally got all the locations corrected. No errors. But no output either. I'm going to read the documentation again. I'm feeling pretty stupid just now.
[jQuery] Re: $ is not defined
Could you provide an example of this online? - jake On Tue, May 6, 2008 at 12:33 PM, mdg583 [EMAIL PROTECTED] wrote: Hi, I don't know where this problem is coming from, but I find that over the course of a few jquery AJAX operations and a ajaxForm submit, for a little while I find that $ is not defined. Basically, I am loading a form into the current document using the jquery load function, and then setting up ajaxForm to submit this form and put the results into another div. This content that is finally loaded into this next div div has a javascript function near the beginning, and at the point in time when this script is reached, I find that $ is not defined. This happened once before and I just worked around it, but that is getting difficult. Does anyone know why this would be? I have jquery.form that says it requires jQuery v1.1 or later, and I have jQuery 1.2.1.
[jQuery] Re: $ is not defined
When ever I get the $ not defined error, its because my core jQuery library is not there, for example when I switch from jquery.pack to jquery.min and I forget to change the script tag reference in the head. Just double check that its properly referenced and that jQuery is listed above jquery.form. On May 6, 12:45 pm, Jake McGraw [EMAIL PROTECTED] wrote: Could you provide an example of this online? - jake On Tue, May 6, 2008 at 12:33 PM, mdg583 [EMAIL PROTECTED] wrote: Hi, I don't know where this problem is coming from, but I find that over the course of a few jquery AJAX operations and a ajaxForm submit, for a little while I find that $ is not defined. Basically, I am loading a form into the current document using the jquery load function, and then setting up ajaxForm to submit this form and put the results into another div. This content that is finally loaded into this next div div has a javascript function near the beginning, and at the point in time when this script is reached, I find that $ is not defined. This happened once before and I just worked around it, but that is getting difficult. Does anyone know why this would be? I have jquery.form that says it requires jQuery v1.1 or later, and I have jQuery 1.2.1.
[jQuery] Re: $ is not defined
It can be becaused the $ was used by another library like in wordpress admin (if i am not wrong), $ is assigned to their own lib. so try to use this : jQuery('#yourid').val(); :) On May 6, 11:57 pm, motob [EMAIL PROTECTED] wrote: When ever I get the $ not defined error, its because my core jQuery library is not there, for example when I switch from jquery.pack to jquery.min and I forget to change the script tag reference in the head. Just double check that its properly referenced and that jQuery is listed above jquery.form. On May 6, 12:45 pm, Jake McGraw [EMAIL PROTECTED] wrote: Could you provide an example of this online? - jake On Tue, May 6, 2008 at 12:33 PM, mdg583 [EMAIL PROTECTED] wrote: Hi, I don't know where this problem is coming from, but I find that over the course of a few jquery AJAX operations and a ajaxForm submit, for a little while I find that $ is not defined. Basically, I am loading a form into the current document using the jquery load function, and then setting up ajaxForm to submit this form and put the results into another div. This content that is finally loaded into this next div div has a javascript function near the beginning, and at the point in time when this script is reached, I find that $ is not defined. This happened once before and I just worked around it, but that is getting difficult. Does anyone know why this would be? I have jquery.form that says it requires jQuery v1.1 or later, and I have jQuery 1.2.1.
[jQuery] Re: $ is not defined
yeah I get that error when libraries conflict. We are using the Prototype and jQuery libraries together on a project. If it is an issue of multiple libraries using the $, try the above solution of using jQuery() instead of $(). Also look into the jQuery noConflict function. On May 6, 5:42 pm, Adwin Wijaya [EMAIL PROTECTED] wrote: It can be becaused the $ was used by another library like in wordpress admin (if i am not wrong), $ is assigned to their own lib. so try to use this : jQuery('#yourid').val(); :) On May 6, 11:57 pm, motob [EMAIL PROTECTED] wrote: When ever I get the $ not defined error, its because my core jQuery library is not there, for example when I switch from jquery.pack to jquery.min and I forget to change the script tag reference in the head. Just double check that its properly referenced and that jQuery is listed above jquery.form. On May 6, 12:45 pm, Jake McGraw [EMAIL PROTECTED] wrote: Could you provide an example of this online? - jake On Tue, May 6, 2008 at 12:33 PM, mdg583 [EMAIL PROTECTED] wrote: Hi, I don't know where this problem is coming from, but I find that over the course of a few jquery AJAX operations and a ajaxForm submit, for a little while I find that $ is not defined. Basically, I am loading a form into the current document using the jquery load function, and then setting up ajaxForm to submit this form and put the results into another div. This content that is finally loaded into this next div div has a javascript function near the beginning, and at the point in time when this script is reached, I find that $ is not defined. This happened once before and I just worked around it, but that is getting difficult. Does anyone know why this would be? I have jquery.form that says it requires jQuery v1.1 or later, and I have jQuery 1.2.1.
[jQuery] Re: $ is not defined error
If you're certain your path is correct, another possibility may be that you're calling $ before you've included the jQuery lib. If that still doesn't do it, I'd take a look at your path again. On Apr 17, 3:07 pm, dustinl [EMAIL PROTECTED] wrote: I get this error in the Firefox error console: $ is not defined and it points me to line $(document).ready( function() { I have the most up to date jQuery and I am pointing it to the correct location but I can't figure out why I get this error. Anybody else experience this?
[jQuery] Re: $ is not defined error
On Apr 17, 2008, at 2:07 PM, dustinl wrote: I get this error in the Firefox error console: $ is not defined and it points me to line $(document).ready( function() { I have the most up to date jQuery and I am pointing it to the correct location but I can't figure out why I get this error. Anybody else experience this? That seems to indicate that the page isn't correctly loading jQuery. Are you sure you're correctly pointing the the jquery file? You also have to include the jquery file BEFORE using $(document).ready(). If you can put an example page online, I'm sure someone here will figure the problem out. --dave
[jQuery] Re: $ is not defined error
On Donnerstag, 17. April 2008, dustinl wrote: I get this error in the Firefox error console: $ is not defined and it points me to line $(document).ready( function() { I have the most up to date jQuery and I am pointing it to the correct location but I can't figure out why I get this error. Anybody else experience this? No. Please show a real-life example. Christoph -- When you do things right people won't be sure you've done anything at all. signature.asc Description: This is a digitally signed message part.
[jQuery] Re: Attach pre-defined events to loaded dom elements?
On Jul 27, 7:06 pm, Karl Swedberg [EMAIL PROTECTED] wrote: The answer to this question is, in fact, on that page;http://docs.jquery.com/ Frequently_Asked_Questions#Why_do_my_events_stop_working_after_an_Ajax_r equest.3F That FAQ entry was really useful, however that plugin doesn't work with $.ajax, even though the FAQ would suggest it does.
[jQuery] Re: Attach pre-defined events to loaded dom elements?
I think this is what you need : http://www.learningjquery.com/2006/09/sacrificial-lambda -- David Phillip B Oldham schreef: Hi all I have a document with some links with a certain class. When loaded, some events are attached to these links. I'm then using $().load() to grab a HTML fragment and append it to the DOM. Inside this HTML fragment are more links with aforementioned class. Is there a way I can globally attach the relevant events to the newly loaded dom elements without being specific? I'm trying to move this code into a plugin.
[jQuery] Re: Attach pre-defined events to loaded dom elements?
Perfect! Thanks for your help. On Jul 27, 9:22 am, David Duymelinck [EMAIL PROTECTED] wrote: I think this is what you need :http://www.learningjquery.com/2006/09/sacrificial-lambda -- David Phillip B Oldham schreef: Hi all I have a document with some links with a certain class. When loaded, some events are attached to these links. I'm then using $().load() to grab a HTML fragment and append it to the DOM. Inside this HTML fragment are more links with aforementioned class. Is there a way I can globally attach the relevant events to the newly loaded dom elements without being specific? I'm trying to move this code into a plugin.
[jQuery] Re: Attach pre-defined events to loaded dom elements?
Some of these questions that get asked over and over on the list should really be on the jQuery FAQ: http://docs.jquery.com/Frequently_Asked_Questions -Dan -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of David Duymelinck Sent: Friday, July 27, 2007 4:22 AM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Attach pre-defined events to loaded dom elements? I think this is what you need : http://www.learningjquery.com/2006/09/sacrificial-lambda -- David Phillip B Oldham schreef: Hi all I have a document with some links with a certain class. When loaded, some events are attached to these links. I'm then using $().load() to grab a HTML fragment and append it to the DOM. Inside this HTML fragment are more links with aforementioned class. Is there a way I can globally attach the relevant events to the newly loaded dom elements without being specific? I'm trying to move this code into a plugin.
[jQuery] Re: Attach pre-defined events to loaded dom elements?
The answer to this question is, in fact, on that page; http://docs.jquery.com/ Frequently_Asked_Questions#Why_do_my_events_stop_working_after_an_Ajax_r equest.3F The problem is that the question can be asked in a million different ways. It's hard for someone new to all of this with a limited JS vocabulary and a tenuous grasp of some of the basics to know that question A is actually the same as question Y. I suspect this is a common problem in online technology-oriented communities (although I wouldn't know from experience, not ever having been part of one before jQuery). --Karl _ Karl Swedberg www.englishrules.com www.learningjquery.com On Jul 27, 2007, at 8:06 AM, Dan G. Switzer, II wrote: Some of these questions that get asked over and over on the list should really be on the jQuery FAQ: http://docs.jquery.com/Frequently_Asked_Questions -Dan -Original Message- From: jquery-en@googlegroups.com [mailto:jquery- [EMAIL PROTECTED] On Behalf Of David Duymelinck Sent: Friday, July 27, 2007 4:22 AM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Attach pre-defined events to loaded dom elements? I think this is what you need : http://www.learningjquery.com/2006/09/sacrificial-lambda -- David Phillip B Oldham schreef: Hi all I have a document with some links with a certain class. When loaded, some events are attached to these links. I'm then using $().load() to grab a HTML fragment and append it to the DOM. Inside this HTML fragment are more links with aforementioned class. Is there a way I can globally attach the relevant events to the newly loaded dom elements without being specific? I'm trying to move this code into a plugin.