On Jan 28, 8:23 am, "saiful.ha...@gmail.com" <saiful.ha...@gmail.com>
wrote:
> 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 ~


Hi saiful,

1 = try to define ur behave(); function in that .js file where ur
above ajax
code.
2 = - if u have another .js file for behave(); function
    - if ur bringing html file with response then include ur .js file
in that html response like this
<script type="text/javascript" src="rating.js"  charset="utf-8"></
script>

hope this will work.

regards
Regx :)

Reply via email to