I am using Jquery Form Plugin to submit my form. The head tag of my html file looks like following
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
then 10 other javascript files
AND Then
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery.form.js">
<script type="text/javascript">
$(document).ready(function() {
var options = {
success: showResponse
};
$('#myForm').ajaxForm(options);
});
</script>
To see the actual picture of my code please check this http://jsfiddle.net/Xfrms/1/
The problem is even though I call jquery library
on the very top of my code, if I don't call the jquery library right before the jquery.form.js plugin then it (jquery.form.js) doesn't work. I have tried to call those 10 other javascript files after the query.form.js
plugin calling the jquery library on the very top but in this case the functionality for which the javascript files are being called doesn't work.
After seeing this post, I think calling jquery twice can cause problems.
Could you please tell me what could possibly going wrong in my code and how to avoid having to load jquery right before the the jquery form plugin but still get it working?
Thanks
As I can imagine your problem is that some of the other libraries is using the $ keyword markup to instantiate each calls. If I am correct the just try the following and you will be all set to go..
var $jq = jQuery.noConflict();
Then for all of your jquery calls try use your new markup.. the $jq.
For more detailed info check out this page: http://docs.jquery.com/Using_jQuery_with_Other_Libraries
Use the js script reference at the beginning of your page to ensure that all code is loaded properly at start. Moreover it is likely that some error could be populated from loading all scripts.. To check if any errors exist, use some debugging plug in like Firebug.
Have you tried:
window.jQuery || document.write('<script src="js/jquery-1.7.2.min.js"><\/script>')
来源:https://stackoverflow.com/questions/11637392/how-can-i-avoid-calling-jquery-twice