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 8118103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:22:49+00:00 2026-06-06T04:22:49+00:00

I have a slider with 3 slides – Intro, Question, Submit. Now I want

  • 0

I have a slider with 3 slides – Intro, Question, Submit.

Now I want to make sure that if the question is answered wrong people cannot slide to Submit.

The function to move slide is like this:

function changeSlide(slide){

        // In case current slide is question check the answer
        if (jQuery('.modalSteps li.current',base).hasClass('questionStep')){
            checkAnswer(jQuery('input[name="question_id"]',base).val(), jQuery('input[name="answer"]:checked',base).val());
        }

        jQuery('.modalSteps li.current',base).fadeOut('fast',function(){
            jQuery(this).removeClass('current');
            jQuery(slide).fadeIn('fast',function(){
                jQuery(slide).addClass('current');
            });
        });

        // In case the new slide is question, load the question
        if (jQuery(slide).hasClass('questionStep')){
            var country = jQuery('input[name="country"]:checked',base).val();
            loadQuestion(country);
        }
    }

Now as you can see on first lines, I am calling function checkAnswer, which takes id of question and id of answer and pass it to the AJAX call.

function checkAnswer(question, answer){
        jQuery.ajax({
            url: window.base_url+'ajax/check_answer/'+question+'/'+answer+'/',
            success: function(data){
                if (!data.success){
                    jQuery('.question',base).html(data.message);
                }
            }
        });
    }

The problem i am having is that I cannot say

if(checkAnswer(...)){}

Because of Ajax it always returns false or undefined. What I need is something like this:

 function changeSlide(slide){

        // In case current slide is question check the answer
        if (jQuery('.modalSteps li.current',base).hasClass('questionStep')){
            if (!checkAnswer(jQuery('input[name="question_id"]',base).val(), jQuery('input[name="answer"]:checked',base).val())){
              return false;
            }
        }
...

So it will prevent the slide from moving on.

Now when I’m thinking about it, I will probably have slide like "Wrong answer" so I could just move the slide there, but I would like to see the first solution anyway.

  • 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-06-06T04:22:50+00:00Added an answer on June 6, 2026 at 4:22 am

    You can set option async of ajax to false to wait for the reply from server. Therefore, the code may be like the below.

    function checkAnswer(question, answer){
        result = false;
        jQuery.ajax({
            async: false,
            url: window.base_url+'ajax/check_answer/'+question+'/'+answer+'/',
            success: function(data){
                result = data.success
                if (!data.success){
                    jQuery('.question',base).html(data.message);
                }
            }
        });
    
        return result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this javascript code that creates a slider: http://jsfiddle.net/samccone/ZMkkd/ Now, i want to
I have an image slider that slides automatically. Because I'm nice, I want to
I have a slider that slides the content from the top to bottom when
I have a web site with a jQuery slider that automatically slides when the
I'm building a new page where I want to include a slider that slides
I have a slider that slides images across on the click of a button
I have Slider in my app that is connected to a few methods. In
I have a slider on my page. What I want to do is, to
I have a StackPanel inside of a ScrollViewer. I have a slider that does
I have used jQuery ready slider by: http://www.jeremymartin.name/projects.php?project=kwicks I now need to put overlay

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.