Home » Blog » Uncategorized

Category: Uncategorized

happy woman with laptop

Yay! It Works!

Yay – it works!  Famous words of a developer when they finally get some code to magically work.

Have you ever come to an error in your code and it drives you crazy trying to find that one thing that is making not work.  Sometimes it is simple like a missing semicolon but you have been staring at it too long to see it.  Other times it is in the wrong order like on an HTML file calling in some JavaScript links but they were added in the wrong place.

I have had that happen to me many times.  It’s frustrating when you are looking through your code and you know it has to be something so small that you are just missing it.  You google the error you’re getting and you try changing things you know are working but something just isn’t right.

I am currently working on revamping the design of this site and was working on the Front Page and setting it up like a landing page.  I know I had the HTML and the CSS correct.  It was showing up correctly.  I know the JavaScript/jQuery was correct per checking it against multiple googled places on the net.  But for some reason it just wasn’t executing.  I couldn’t figure it out why.  I was getting the “$ is not defined” error message.  Googled it and saw several different ways to run jQuery in a JavaScript file.

Here are a few examples:

$(document).ready(function () {
  //your code here
});
$(function () {
  //your code here
});
$(function () {
  //your code here
})(jQuery);
jQuery(function () {
  //your code here
});

I tried them all and no luck.  The JavaScript still would not execute.

Then during one of my changes I saw a different error come up with the other one.  One of my script links for MailChimp didn’t have the SRC correct.  It was missing the “http:” part, it just started with “//”.  I made that correction and BOOM the rest of my JavaScript finally executed.  I decided to change my JavaScript code back to what it was before all the changes from googled suggested sites and it still worked.

Just goes to show, sometimes it isn’t your code missing a semicolon but a link that is messing it all up.  Now I can finish the rest of my theme to match the front page and my newly revamped site will go live.  Yay! It Works!

Now I’m off to celebrate like a rock star because you know, I’m excited it works!