hi all,

I have 2 file

rating.js
$(document).ready(function() {
  var behav = function(){
    $(".rating_class").hover(function(){
      $("#tooltip_star").css({"visibility":"visible", "top":($
(this).offset().top - 60), "left":($(this).offset().left+$(this).width
()+ 2)});
      $.ajax({
        type: "POST",
        url: $(this).attr("href"),
        success: function(msg){
          $("#tooltip_star").html(msg);
        }
      });
    }, function(){
      $("#tooltip_star").css("visibility","hidden");
    }).ajaxStart(function(){
      $("#tooltip_star").html("<table class=\"table_animation
\"><tr><td><img style=\"text-align:center\" src=\"/resource/images/
loading.gif\"></td></tr></table>");
    });

    $(".rating_class").click(function(){
      location = $(this).attr("href").replace("ajax_", "");
      return false;
    });
  }

  behav();
});

there is just call function behav(); to run all sintax in this file,

and i have some ajax sintax in other file file this

$(document).ready(function() {

var mainApp = function(page){
      $.ajax({
        type: "POST",
        url: "<?= base_url();?>product/related/<?= $idProduct ?
>/"+page,
        success: function(msg){
          $("#displayRelated").html(msg);
          behav();
        }
      });
    }

    mainApp(1);

});

But i get some error in my firebug like this

behav is not defined
success()()6 (line 652)
success()jquery-1.2.6.js (line 2818)
onreadystatechange()()jquery-1.2.6.js (line 2773)
[Break on this error] behav();

my question is, why my function behav() in rating.js can't called from
success: function(msg){...}, there is need something like global
function?

thang's

~ saiful haqqi ~

Reply via email to