Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4111164
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:01:52+00:00 2026-05-20T22:01:52+00:00

I am using jCarousel. I created a button New Posts, when the user click

  • 0

I am using jCarousel. I created a button “New Posts”, when the user click on “New Posts” button, it will recall a javascript function goer() to get the new records from database and display the new records on the website. My problem is everytime the user click on “New Posts” button, it will reload the page. I don’t want it reload the page, how to use Ajax to prevent reload page? Below is my codes :

function mycarousel_itemLoadCallback(carousel, state)
{
    // Since we get all URLs in one file, we simply add all items
    // at once and set the size accordingly.
    if (state != 'init')
        return;
var str="<?php echo $username1; ?>";
    jQuery.get("usermessage.php?username="+str, function(data) {                                                     
        mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, data);
    });
};

function mycarousel_itemAddCallback(carousel, first, last, data)
{
    // Simply add all items at once and set the size accordingly.
    var items = data.split('|');
    for (i = 0; i < items.length; i++) {
        carousel.add(i+1, mycarousel_getItemHTML(items[i]));
    }
    carousel.size(items.length);
};

function mycarousel_getItemHTML(url)
{
    return '<li style="width:300px; height:30px;">' + url + '</li>';
};

function goer(){
    jQuery('#mycarousel').jcarousel({                     
        itemLoadCallback: mycarousel_itemLoadCallback,
        vertical: true,
        scroll: 7,
        visible: 9,
        animation: 0
    });
};

function getnewposts(){
    goer();
}

<a href="" onclick="getnewposts()">New Posts</a>

Is it I need to use Ajax to retrieve data from usermessage.php and use Ajax to display data on website then the page will not reload anymore? I don’t know how to convert the jquery code of retrieving data into Ajax code. Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:01:53+00:00Added an answer on May 20, 2026 at 10:01 pm

    Ok, I got the answer already. <a href="javascript: return false" onclick="getnewposts()"> or <a href="#" onclick="getnewposts()"> can prevent page is loaded.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using jCarousel Lite and need to get the current index (which element is
I'm currently using JCarousel to highlight featured posts in Wordpress. The carousel displays above
I've created an app that shows 8 buttons in coverflow using icarousel.i have to
I am using jcarousel on a page in 3 different sections. I initially show
I am using jcarousel to auto scroll some images. I would like to know
I'm using JCarousel to display a circular carousel of 5 divs. All of the
I'm using simple jcarousel here is ther code: http://jsfiddle.net/w6fLA/ I'm trying to show div
I am using a AJAX gallery called jCarousel, and I am having some difficulties
Using the TinyCarousel program I created the following sample page. http://www.dealred.com/wa/jqimage.htm The carousel is
I am using JCarousel to display some ads. Everything works fine, except when there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.