If I understand you write you need to make you own js page and the link that to 
each page. The you only have the 
function in one place.
<script type="text/javascript" src="js/myjavascript.js"></script>

You can place all of your own function in this js page and then call them as 
you want from the individual page. Or 
you can have the script called automatically by adding a class that is observed.

$(document).ready(function(){
  if($(".addRecord").length) {
      addRecord();
  }
});

>  -------Original Message-------
>  From: Dave Maharaj :: WidePixels.com <d...@widepixels.com>
>  To: jquery-en@googlegroups.com
>  Subject: [jQuery] Function help
>  Sent: Jan 12 '10 11:59
>  
>  I have this function:
>  
>  $('#new').live('click', addRecord);
>  
>  
>  function addRecord() {
>  
>  var data = $('#add').serialize();
>  
>  $.ajax({
>    type: "post",
>           url: "/manage/add",
>           data: data,
>           dataType: 'json',
>           success: function(response){
>     if (response.status === true) {
>      alert(response.status);
>                  
>        });
>     } else {
>      alert(response.status);
>         }
>    }
>  });
>      }
>  
>  So it works fine but I have this in 5 pages on the site and was wondering
>  how can I turn this into a standard function and call it like:
>  
>  addRecord(form_id);
>  
>  So I only need to place this on the page rather thanthe same script all over
>  the site.
>  
>  Thanks
>  
>  Dave
>  
>  

Reply via email to