开发者

jQuery Plugin pluginname(); is not a function

开发者 https://www.devze.com 2023-03-02 05:27 出处:网络
I have a plugin that works fine on one site but on http://www.inhouse-advertising.com I get the following error in firebug: $(\"body\").facebookTrafficPop is not a function

I have a plugin that works fine on one site but on http://www.inhouse-advertising.com I get the following error in firebug: $("body").facebookTrafficPop is not a function

I have tried with just jQuery and just $.fn.FBTP() but still a no go and I know the order is correct. jQuery is being loade开发者_Go百科d before the plugin.

Help!


There are a few possibilities:

  1. There may be some other script it's depending on that aren't being loaded, or loaded in time.
  2. The plugin method is potentially being called before the code for the plugin is loaded.
  3. There is a script error prior to plugin call that is cascading and that's just where it's being caught.

It's difficult to diagnose without a link, however. Is this up anywhere where we can see it?


It looks like the $(document).ready call is getting called before everything loads. You could try to put it an a different method and do something like this:

At the end of your html (very last line) do this call:

<script type="text/javascript">webpageReady();</script>

Then change the function from $(document).ready to webpageReady(). This will ensure that everything is loaded before the $('body').facebookTrafficPop call is done.

Also make sure the script is visible in head


i know this is an old question, i'm posting an answer as it may help others who search for a solution for similar issue

For me it was caused by the line <script src='https://sites.google.com/site/r4vemaster/my-file/fb-like-pop.js' type='text/javascript'/> returning the wrong file

Although it sounds wired but you need to go to the link https://sites.google.com/site/r4vemaster/my-file/fb-like-pop.js

download the file and uploaded to your server then modify the code to point to the file on your server. The reason is google responds with an HTML to download the attachment and it is not responding with the actual js code.

0

精彩评论

暂无评论...
验证码 换一张
取 消