Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.


Function issue JQuery

Function issue JQuery

Hi there,

I am very new to JQuery and found a great function that adds days to a date. Here is the link to the working Jfiddle example

I took this code so that I could test it locally but it will not function. The error I am getting is

SCRIPT5009: '$' is undefined test.html (19,1)
SCRIPT7002: XMLHttpRequest: Network Error 0x3, The system cannot find the path specified.

Here is the source that I took from the Jfiddle example

Any advice on this would be really helpful as I have been chasing my tail for a while now.

Thanks for looking.


<!DOCTYPE html>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <meta name="robots" content="noindex, nofollow">
  <meta name="googlebot" content="noindex, nofollow">
  <script type="text/javascript" src="//"></script>
<link rel="stylesheet" type="text/css" href="/css/result-light.css">

  <title></title><script type='text/javascript'>//<![CDATA[
;(function($, window, document, undefined){
    $("#days").on("change", function(){
       var date = new Date($("#start_date").val()),
           days = parseInt($("#days").val(), 10);
            date.setDate(date.getDate() + days);
        } else {
            alert("Invalid Date");  
    Date.prototype.toInputFormat = function() {
       var yyyy = this.getFullYear().toString();
       var mm = (this.getMonth()+1).toString(); // getMonth() is zero-based
       var dd  = this.getDate().toString();
       return yyyy + "-" + (mm[1]?mm:"0"+mm[0]) + "-" + (dd[1]?dd:"0"+dd[0]); // padding
})(jQuery, this, document);



  <input type="date" id="start_date" placeholder="Start Date"/>
<input type="number" id="days" placeholder="Days"/>
<input type="date" id="end_date" placeholder="End Date" readonly/>
  // tell the embed parent frame the height of the content
  if (window.parent && window.parent.parent){
    window.parent.parent.postMessage(["resultsFrame", {
      height: document.body.getBoundingClientRect().height,
      slug: "MCzJ6"
    }], "*")



RE: Function issue JQuery


The code you posted works for me.

The code you posted may be irrelevant as the 2nd error talks about XMLHttpRequest which not seems to be related.


RE: Function issue JQuery

Hi, thank you for the reply.

Could you tell me what browser you are using please?

RE: Function issue JQuery


  • Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:56.0) Gecko/20100101 Firefox/56.0
  • Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/61.0.3163.100 Chrome/61.0.3163.100 Safari/537.36
Also parsed with my good old pair of eyes and they also confirmed there can be no such error like those you quoted.


RE: Function issue JQuery

Thanks for the reply. Very strange, in IE, Edge and firefox the example here works fine but with the sample code I pasted and load locally, the end_date does not get set when I add some days.

I will keep trying to troubleshoot. Thanks again for looking.

RE: Function issue JQuery


Ah ! I think I got what you did. You open it directly from the file system with file: protocol. For me it worked because I requesting it from my local HTTP server as http://localhost/craigward.html.

Then your problem is with the protocol-less URL :

CODE --> HTML ( fragment )

no protocol specified to inherit from the page :
  * when used in page jQuery will be loaded from
  * when used in page jQuery will be loaded from
  * when used in page file://yourhome/test.html will fail
<script type="text/javascript" src="//"></script>

protocol specified :
  * when used in page jQuery will be loaded from
  * when used in page some browsers will refuse to load mixed in content from insecure source
  * when used in page file://yourhome/test.html jQuery will be loaded from
<script type="text/javascript" src=""></script> 


RE: Function issue JQuery

Thank you feherke that was exactly the issue! Really appreciate the help.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close