jQuery 注意事项 与原因分析

  1.在一个方法之外,一定要有个jQuery的全局方法启动,例如我要调用a方法做ajax提交,那么在页面的任一<script></script>标签内,加入jQuery(function(){}),而且这句话要放在全局,不能在方法块里面,否则a方法的jQuery.post()则不会起作用:

  

复制代码 代码如下:

  <head>

  <script>

  jQuery(function(){})

  function a(url){

  jQuery.post(url);

  }

  </script>

  </head>