开发者

How can I load my google jquery in MVC3

开发者 https://www.devze.com 2023-03-09 08:48 出处:网络
I have tried this: <script src=\"//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js\" type=\"text/javascript\"></script>

I have tried this:

  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>
  <script src="//ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.unobtrusive-ajax.min.js" type="text/javascript"></script>
  <script src="//ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.min.js type="text/javascript"></script>
  <link  href="@Url.Content("~/Content/Stylesheets/selectbox.css")" rel="stylesheet" type="text/css" />
  <script 开发者_开发技巧src="@Url.Content("~/Scripts/jquery.selectbox-0.5.js")" type="text/javascript"></script>
  <script type="text/javascript">
      window.jQuery || document.write('<script src="/Scripts/jquery/jquery-1.6.1.min.js">\x3C/script>')
      window.jQuery || document.write('<script src="/Scripts/jquery/jquery.unobtrusive-ajax.min.js">\x3C/script>')
      window.jQuery || document.write('<script src="/Scripts/jquery/validate.validate.min.jss">\x3C/script>')

If I'm not connected to the internet and running locally then it just hangs. Is there just one good recommended way to load up external javascrpt such as those from google. Maybe something that I can code into my view that checks if the internet is available and then if not it loads local scripts?


one more option to detect jquery plugins are available/loaded or not::

if(typeof jQuery.fn.**PLUGIN_FUNCITON_NAME** == 'function'){
    //jQuery plugin calling goes here
}

but it must be called after jQuery itself loaded successfully... for to check jQuert, try this:

if (typeof jQuery == 'undefined'){
    //jQuery scripting goes here
}
0

精彩评论

暂无评论...
验证码 换一张
取 消