From one jquery file to another

I have two javascript files that execute some code. One is a default file loaded on all pages that executes some jquery for some bells and whistles for basic interactivity :

default_jquery.js


$(document).ready(function() {

function make_fancy(){
//make tables look nice
//make hover look nice
//etc
//etc
}

make_fancy();

});

It works great. However, one of my pages updates a database via ajax and then rewrites and redisplays the updated table on a successful ajax return. For example, if someone adds something to their shopping cart, ajax queries the database, updates an entry, and then rebuilds the shopping cart to reflect the new item or quantity. The problem I was having was that after the rewrite of the table, I was losing the formatting that the above jquery file was implementing. So I just added the same jquery statements above to the success indicator of the ajax.

My ajax looks something like this:
buy_item.js


  $.ajax({  
    type: "POST",  
    url: "../buy_item.php",  
    data: "item="+item+"&quantity="+quantity,  
    success: function(resp){  
//redraw table
[color=green]
//make tables look nice (same jquery as above)
//make hover look nice (same jquery as above)
//etc (same jquery as above)
//etc (same jquery as above)
[/color]
    },  
    error: function(e){  
      alert('You suck at this');  
    }  
  });  
   
}//function

This works fine, and reapplies the styles after the table has been redrawn. However, I don’t like to have the same jquery statements in this file as I do in the standard jquery file above. So I just want to use a function. So on this buy_item.js page, I’m trying to call the make_fancy() function in the default_jquery.js file, but it doesn’t work. I’m told that the make_fancy() function is not defined.

I’ve tried including the default_jquery.js file which contains the make_fancy function before the buy_item.js file that calls it, but that doesn’t work for some reason.

What I want is this for the buy_item.js page:


$.ajax({  
    type: "POST",  
    url: "../buy_item.php",  
    data: "item="+item+"&quantity="+quantity,  
    success: function(resp){  
//redraw table
[b][color=red]make_fancy();[/color][/b]
    },  
    error: function(e){  
      alert('You suck at this');  
    }  
  });  
   
}//function

Any ideas?

Thanks in advance.

I can work on stuff for hours and make little to no headway… then come post here for help and I kid you not in the next 5 minutes I will have figured out the problem. :wink:

In case anyone else reads this and has a similar problem, I just needed to change this:


$(document).ready(function() {

function make_fancy(){
//make tables look nice
//make hover look nice
//etc
//etc
}

make_fancy();

});

To this:


function make_fancy(){
//make tables look nice
//make hover look nice
//etc
//etc
}

$(document).ready(function() {
make_fancy();

});