最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - My jquery slider is not working properly - Stack Overflow

programmeradmin4浏览0评论

I'm pretty new with JQuery, I'm trying to get this script to work. I'm trying to create a rotator on the homepage of a clients website but I can't get it to run! I get no errors, the files are were they're supposed to be, I can't for the life of me figure out what the problem is!

Here's a snipped of the code:

<script src=".js"></script>
<script src="jquery.bxSlider.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
    $("form#newsletter-form").submit(function () {
        $.post("/newsletter.ajax.php", {
            action: 'subscribe',
            email: $("form#newsletter-form input#email").val()
        }, function (json) {
            if (json.success == true) {
                $("div.form-container").empty().append("<p>Thank you for submitting your info.</p>");
            } else {
                alert(json.error);
            }
        }, 'json');
        return false;

        $(function () {
            $('#show-options').click(function () {
                $('#options').slideToggle();
                $(this).toggleClass('open');
                return false;
            });
        });

        $('#slider1').bxSlider({
            infiniteLoop: false,
            auto: true,
            pager: true
        });
    });
});
</script>

The slider is what I'm trying to get to run, I wonder if the problem has to do with the function above it or if there's a conflict.

Thank You.

I'm pretty new with JQuery, I'm trying to get this script to work. I'm trying to create a rotator on the homepage of a clients website but I can't get it to run! I get no errors, the files are were they're supposed to be, I can't for the life of me figure out what the problem is!

Here's a snipped of the code:

<script src="http://code.jquery./jquery-latest.js"></script>
<script src="jquery.bxSlider.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
    $("form#newsletter-form").submit(function () {
        $.post("/newsletter.ajax.php", {
            action: 'subscribe',
            email: $("form#newsletter-form input#email").val()
        }, function (json) {
            if (json.success == true) {
                $("div.form-container").empty().append("<p>Thank you for submitting your info.</p>");
            } else {
                alert(json.error);
            }
        }, 'json');
        return false;

        $(function () {
            $('#show-options').click(function () {
                $('#options').slideToggle();
                $(this).toggleClass('open');
                return false;
            });
        });

        $('#slider1').bxSlider({
            infiniteLoop: false,
            auto: true,
            pager: true
        });
    });
});
</script>

The slider is what I'm trying to get to run, I wonder if the problem has to do with the function above it or if there's a conflict.

Thank You.

Share Improve this question edited Oct 19, 2010 at 16:59 user372551 asked Oct 19, 2010 at 16:45 CoreyCorey 211 silver badge2 bronze badges 4
  • This is the error I get - $("#slider1").bxSlider is not a function – Corey Commented Oct 19, 2010 at 17:00
  • None of that code after return false will do anything...because the function will have returned already. It should be outdented a level, and the $(function... part in the middle isn't needed because you're already inside a ready event – Michael Haren Commented Oct 19, 2010 at 17:02
  • Modified it, made it a little more simple, petconn.blackdogstaging. – Corey Commented Oct 19, 2010 at 17:09
  • Hi Corey, I am having the same issue with bxSlider - will you please let me know what solution you found? Thanks! – user631143 Commented Feb 24, 2011 at 2:07
Add a ment  | 

3 Answers 3

Reset to default 6

I had this same problem, but resolved the issue by using jQuery.noConflict:

    var j = jQuery.noConflict();
    j(document).ready(function () {
       j('#slider1').bxSlider();
});

I had the same problem... i was editing the worpress default "twenty ten" theme when i had this problem "bxSlider is not a function". I checked that it loaded properly and everything but couldn't figure it out later i uninstalled a plugin called "TubePress" and the slider started working somehow. I tried it again by installing that pluggin and running bxslider again and i got the same error. So i am pretty sure that it was due to conflict with some of the scripts that were loaded by that plugin which created that problem.

So my suggestion is that you can just go on unmenting scripts to find out which script is conflicting wth bxslider.

Sorry this is not a very convincing solution but that is what i have right now though i'll update my answer if i find out what exactly is causing this problem.

It is most likely because the src to your slider script is not correct:

<script src="jquery.bxSlider.min.js" type="text/javascript"></script>

======================^ It isn't valid path
发布评论

评论列表(0)

  1. 暂无评论
ok 不同模板 switch ($forum['model']) { /*case '0': include _include(APP_PATH . 'view/htm/read.htm'); break;*/ default: include _include(theme_load('read', $fid)); break; } } break; case '10': // 主题外链 / thread external link http_location(htmlspecialchars_decode(trim($thread['description']))); break; case '11': // 单页 / single page $attachlist = array(); $imagelist = array(); $thread['filelist'] = array(); $threadlist = NULL; $thread['files'] > 0 and list($attachlist, $imagelist, $thread['filelist']) = well_attach_find_by_tid($tid); $data = data_read_cache($tid); empty($data) and message(-1, lang('data_malformation')); $tidlist = $forum['threads'] ? page_find_by_fid($fid, $page, $pagesize) : NULL; if ($tidlist) { $tidarr = arrlist_values($tidlist, 'tid'); $threadlist = well_thread_find($tidarr, $pagesize); // 按之前tidlist排序 $threadlist = array2_sort_key($threadlist, $tidlist, 'tid'); } $allowpost = forum_access_user($fid, $gid, 'allowpost'); $allowupdate = forum_access_mod($fid, $gid, 'allowupdate'); $allowdelete = forum_access_mod($fid, $gid, 'allowdelete'); $access = array('allowpost' => $allowpost, 'allowupdate' => $allowupdate, 'allowdelete' => $allowdelete); $header['title'] = $thread['subject']; $header['mobile_link'] = $thread['url']; $header['keywords'] = $thread['keyword'] ? $thread['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>