1

When I use JQuery.load, it breaks my other JavaScript libraries. I receive this error:

TypeError: $.doTimeout is not a function

When I do not use jQuery.load it, works fine.

I don't understand causes this to happen. Seems like it couldn't find the function from the JavaScript file that is already rendered on source code.

Scripts

<script type="text/javascript" src="/assets/js/modernizr-1.7.min.js"></script>
<script type="text/javascript" src="/assets/js/jquery.tmpl.js"></script>
<script type="text/javascript" src="/assets/js/jquery.ba-dotimeout.js"></script>
<script type="text/javascript" src="/assets/js/test1.js"></script>
<script type="text/javascript" src="/assets/js/test2.js"></script>

Inside test1.js

$.doTimeout("hoverOut");

Inside test2.js

$(".test").load("/test.aspx?param=" + someValue);

jquery.ba-dotimeout.js is a library

test1.js uses that library to do its fancy stuff

Please help

2
  • 3
    my guess is test.aspx is including a 2nd jquery library that is overriding the first. Commented Jul 17, 2013 at 17:35
  • You are right. Thanks! If you had clicked the "answer question" button, I can put it as an accepted answer. Commented Jul 17, 2013 at 17:45

2 Answers 2

1

This problem is very similar to the one which I struggled for a week.(Now I got rid of it :) ) jQuery UI " $("#datepicker").datepicker is not a function"

Actually, if you are including 2 .js library., you must be sure that., they does not contain definitions for same function.

I don't understand causes this to happen. Seems like it couldn't find the function from the JavaScript file that is already rendered on source code.

Overriding., also could cause the same problem.

Sign up to request clarification or add additional context in comments.

Comments

0

It looks like when you include test.aspx, another copy of jQuery.js is being included which overrides the existing version, thus causing the plugins to be lost (they were on the previous version, but not on the one that was added by test.aspx).

Either remove jquery.js from test.asmx, or add a selector to the .load to filter the results.

$(".test").load("/test.aspx?param=" + someValue + " #targetdivtoload");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.