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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:09:49+00:00 2026-06-09T18:09:49+00:00

I have a form I submit through ajax: $(function() { $(.submit).click(function() { var listid

  • 0

I have a form I submit through ajax:

 $(function() {
 $(".submit").click(function() {
var listid = $("#listid").val();
var itemid = "<?=$id?>";
var userid = "<?=$_SESSION['user_id']?>"; 

 var dataString = 'listid=' + listid + '&userid=' + userid + '&itemid=' + itemid;


 $.ajax({
 type: "POST",
 url: "join.php",
 data: dataString,
 success: function(){
 $('#content_error').fadeIn(200).show();
 }
 });

 return false;
 });
 });

This works perfectly. The ajax function calls join.php:

  <? session_start();

require_once("include/database.php");
$Db = new Database();

 if($_POST['listid'] && $_POST['itemid'] && $_POST['userid']) {

            $list_id = $_POST['listid'];
            $user_id = $_POST['userid'];
            $item_id = $_POST['itemid'];

            $sql = "SELECT *
                    FROM items_list
                    WHERE list_id = '".$list_id."'
                    AND user_id = '".$user_id."'
                    AND item_id = '".$item_id."'
                    ORDER BY item_id DESC LIMIT 1";
            $result = $Db->sQuery($sql);
            $row = mysql_fetch_array($result);

            if(mysql_num_rows($result) > 0){

                $error = "You've already saved this";   

            }else{

            $sql = "INSERT INTO items_list (list_id, user_id, item_id) 
                    VALUES('$list_id', '$user_id', '$item_id')";
            $Db->uidQuery($sql);

            $sql = "SELECT count(item_id) as itemm
                    FROM items_list 
                    WHERE item_id = '".$item_id."'
                    GROUP BY item_id";          
            $result = $Db->sQuery($sql);
            $Db->closeConnection();
            $tel2 = mysql_fetch_array($result);

            ?>
                <span class="bubble_itemm"><?=$tel2['itemm']?></span>


            <?
                $success = "Sucessfully";

            }
        }

?>

After a success I call a span with the class bubble_itemm. This span also exists in the main page. I want the “new” span to replace the “old” span in the main page with a fadein.

How do I do this?

  • 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-09T18:09:51+00:00Added an answer on June 9, 2026 at 6:09 pm

    Form page:

    <script type="text/javascript">
    $(function() {
        $(".submit").click(function() {
            var listid = $("#listid").val();
            var itemid = "<?=$id?>";
            var userid = "<?=$_SESSION['user_id']?>"; 
    
            var dataString = 'listid=' + listid + '&userid=' + userid + '&itemid=' + itemid;
    
    
            $.ajax({
                type: "POST",
                url: "join.php",
                data: dataString,
            }).done(function( result ) {
                myresult(result);
            });
    
            return false;
        });
    });
    
    function myresult(result) {
        var result_lines = result.split("<splitter>");    
        if (result_lines[0] == '1') { 
            $('.bubble_itemm').html('<span class="error">' + result_lines[1] + '</span>').fadeIn(500);
        } else if (result_lines[0] == '2') { 
            $('.bubble_itemm').html('<span class="success">' + result_lines[1] + '</span>').fadeIn(500);
        }
        return true;   
    }
    
    </script>
    

    join.php script:

    <?php 
    
    require_once("include/database.php");
    $Db = new Database();
    
    if($_POST['listid'] && $_POST['itemid'] && $_POST['userid']) {
    
        $list_id = $_POST['listid'];
        $user_id = $_POST['userid'];
        $item_id = $_POST['itemid'];
    
        $sql = "SELECT *
                FROM items_list
                WHERE list_id = '".$list_id."'
                AND user_id = '".$user_id."'
                AND item_id = '".$item_id."'
                ORDER BY item_id DESC LIMIT 1";
        $result = $Db->sQuery($sql);
        $row = mysql_fetch_array($result);
    
        if(mysql_num_rows($result) > 0){
            echo "1<splitter>"; // here to identify message status
            echo "You've already saved this"; // return message
    
        }else{
    
            $sql = "INSERT INTO items_list (list_id, user_id, item_id) 
                    VALUES('$list_id', '$user_id', '$item_id')";
            $Db->uidQuery($sql);
    
            $sql = "SELECT count(item_id) as itemm
                    FROM items_list 
                    WHERE item_id = '".$item_id."'
                    GROUP BY item_id";          
            $result = $Db->sQuery($sql);
            $Db->closeConnection();
            $tel2 = mysql_fetch_array($result);
    
            echo "2<splitter>"; // here to identify message status
            echo $tel2['itemm']; // return message
            echo "Sucessfully"; // return message
    
        }
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that I submit through ajax, and returns an updated chunk
i have a form (made through codeigniter) that i want to submit with ajax
I have this form submit code: Event.observe(window, 'load', init, false); function init() { Event.observe('addressForm',
Possible Duplicate: jQuery AJAX submit form I have a form on a page A,
I have a form where the submit button triggers a function. Let's call it
I have a form where the submit button triggers a function. Let's call it
I have a form with a submit button. I have called a function on
I have a form that submits through Ajax, which works perfectly at the moment.
I am trying to upload and submit through AJAX a form and I found
I have a contact edit form. The entire form is requested through ajax (loaded

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.