Javascript / Jquery functions -
not sure if being totally wrong here want this:
- have external js page (on external server)
 - include page - ok easy etc...
 - have jquery function on external page - many functions
 - call functions directly onto page.
 
all bit this:
external js page:
$(document).ready(function() {  function testit() { $('#test').load('page.php'); }  function testit_1() { $('#test_1').load('page_1.php'); }   function testit_1() { $('#test_2').load('page_2.php'); }  });   then on actual page call:
<script type="script/javascript">   testit();  </script>  <div id="test"></div>   am wrong or should not work?
your functions local scope of anonymous function passed argument $(document).ready(). here's simple example showing behaviour you're seeing:
(function() {     function foo() {         alert("it shouldn't alert this...");     } })();  foo();   to fix it, move function declarations outside of ready function:
function testit() {     $('#test').load('page.php'); }  function testit_1() {     $('#test_1').load('page_1.php'); }   function testit_2() {     $('#test_2').load('page_2.php'); }   and use ready function (shorthand $(function() { ... })) in main js file:
$(function() {     testit_1(); });      
Comments
Post a Comment