Reputation: 231
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
Upvotes: 1
Views: 1409
Reputation: 95054
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");
Upvotes: 0
Reputation: 3307
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.
Upvotes: 1