admin管理员组文章数量:1327284
I'm trying to load JQuery from //ajax.googleapis/ajax/libs/jquery/1.9.1/jquery.min.js
:
<script src="{{ asset('//ajax.googleapis/ajax/libs/jquery/1.9.1/jquery.min.js') }}"></script>
If the file is received, then get it. If not, get the file from the own server:
<script><window.jQuery || document.write('<script src="{{ asset("../app/Resources/public/js/vendor/jquery-1.9.1.min.js") }}"><\/script>')</script>
but it gives me a syntax error. I've tried to scape the quotes but doesn't work:
<script><window.jQuery || document.write('<script src="{{ asset(\"../app/Resources/public/js/vendor/jquery-1.9.1.min.js\") }}"><\/script>')</script>
It gives me again a syntax error. What am I doing wrong?
I'm trying to load JQuery from //ajax.googleapis./ajax/libs/jquery/1.9.1/jquery.min.js
:
<script src="{{ asset('//ajax.googleapis./ajax/libs/jquery/1.9.1/jquery.min.js') }}"></script>
If the file is received, then get it. If not, get the file from the own server:
<script><window.jQuery || document.write('<script src="{{ asset("../app/Resources/public/js/vendor/jquery-1.9.1.min.js") }}"><\/script>')</script>
but it gives me a syntax error. I've tried to scape the quotes but doesn't work:
<script><window.jQuery || document.write('<script src="{{ asset(\"../app/Resources/public/js/vendor/jquery-1.9.1.min.js\") }}"><\/script>')</script>
It gives me again a syntax error. What am I doing wrong?
Share Improve this question asked Oct 29, 2013 at 12:55 ManoloManolo 26.5k21 gold badges89 silver badges134 bronze badges3 Answers
Reset to default 5You can check it with this piece of code:
<script src="http://ajax.aspnetcdn./ajax/jquery/jquery-2.0.0.min.js"></script>
<script>
if (typeof jQuery == 'undefined') {
document.write(unescape("%3Cscript src='/js/jquery-2.0.0.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
You can find the full article with this piece of code here: Jquery CDN fallback
I've finally achieved doing:
<script>
if (typeof jQuery == 'undefined') {
document.write('{% javascripts "../app/Resources/public/js/vendor/jquery-1.9.1.min.js" %} <script src="{{ asset_url }}"><\/script> {% endjavascripts %}');
}
</script>
Try something like this:
<script>
//try to Include from google here
if (typeof jQuery == 'undefined') {
//if not included local source
}
</script>
本文标签:
版权声明:本文标题:javascript - How to load JQuery from the own server, when it is not avaiable from the original source? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742206712a2432953.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论