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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:23:43+00:00 2026-05-25T16:23:43+00:00

I am trying to implement ajax when the button is clicked, but the ajax

  • 0

I am trying to implement ajax when the button is clicked, but the ajax is not wroking, can anyone tell me what’s wrong, many thanks! what I want is that when click the “Move marked to set” button, in the “formstatus” div should display some message I defined in the addtoset.php, but currently it direct to to “#”page instead of remain on the same page

here is my ajax code

    $('#movetoset').click(function() {
   var fail="";
   var hint="";
              if ($('#selectsett').val() === 'General') {

         fail += "Please chooose a set.\n";
    }

  for(j=0;j< array_str_idnum.length;j++)
  {



              if( document.getElementById('check' + array_str_idnum[j]).checked ==false){
                  hint='1';

              }


  }
        if(hint=="1"){
                  fail += "Please check all the box.\n";
              }

      if(fail == ""){

           var str = $("#complicated").serialize();
            $.ajax({
               type: "POST",
               url: "addtoset.php",
               data: str,
                               cache: false,
               success: function(msg)
               {
                    $("#formstatus").ajaxComplete(function(){


                                               $(this).fadeIn("slow").html(msg)

                    });
                }

             });

          return true;
      }else{
          alert(fail);
          return false;
      }


     });

here is my html code

    <form id ="complicated" method = 'post' action = '#'>


    <div class="fancybuttonwrapper" style="margin-left:480px;"><span class="button"><span>
       <input type="submit" class="form_button" id="movetoset" value="  Move Marked to  Set"></span></span> </div>




       <select name="sets" id ="selectsett">
        <option value="General">Select Set</option>
        <option value="Ceremony">Ceremony</option>
        <option value="Lunch">Lunch</option>
        <option value="Garden">Garden</option>
        <option value="Longname">This is max length</option>
      </select>
      </div>

   <div id="formstatus"></div>

  </form>
  • 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-25T16:23:44+00:00Added an answer on May 25, 2026 at 4:23 pm

    your array array_str_idnum is not defined.
    Further, you have to return false, else your form gets posted and so no ajax call at all.

    Try this script. (always return false when you are in a form, else it gets send)

    $('#movetoset').click(function() {
        console.log("here")
        var fail = "";
        var hint = "";
        if ($('#selectsett').val() === 'General') {
    
            fail += "Please chooose a set.\n";
        }
            var str = $("#complicated").serialize();
            $.ajax({
                type: "POST",
                url: "addtoset.php",
                data: str,
                cache: false,
                success: function(msg) {
                    $("#formstatus").ajaxComplete(function() {
    
    
                        $(this).fadeIn("slow").html(msg)
    
                    });
                }
    
            });
    
            return false;
     });
    

    check out: http://jsfiddle.net/wRNQv/5/ there is a running version.

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

Sidebar

Related Questions

I am trying to implement ajax back/forward button support and therefore writing variables after
I am trying to implement paging across ajax calls. The page should not refresh
I'm trying to implement back button on this full ajax website.. I tried jquery
No, I'm not trying to see how many buzzwords I can throw into a
I've been trying to determine whether I can implement AJAX & SSL, so this
I am trying to implement AJAX in my Google App Engine application, and so
I am trying to implement a simple request to Wikipedia's API using AJAX (XMLHttpRequest).
Yesterday I was trying to implement a Listener for a SelectManyListbox using Ajax in
so i'm currently trying to implement a currency conversion script using Jquery, curl, ajax
I am trying to implement ajax in jsp(avoid form submit) using struts2. I used

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.