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

  • Home
  • SEARCH
  • 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 8099885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:33:27+00:00 2026-06-05T22:33:27+00:00

Problem 1: My content overlaps itself twice after I post some data back to

  • 0

Problem 1: My content overlaps itself twice after I post some data back to the same page using jQuery.ajax(). The reason why I’m posting data back to the same page is because I need to pass my JavaScript values to the PHP side.

Question: How do I edit my code such that there will only be 1 copy of my content, before and after posting of data to the same page?


Problem 2: You may have noticed there is a $("#test").html(data); in my bingo function and a <span id="test"></span> in my body. I can’t seem to remove them if not the passing of Javascript values to the PHP side would not work as shown by my print_r().

Question: Is there any way I can remove them but still pass my values from JavaScript to PHP using jQuery.ajax()?


bingo.php

<html>
    <head>
            <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
            <?php
            if (!isset($_POST['varA']) && !isset($_POST['varB']))
            {
            ?>
                <script type="text/javascript">
                $(document).ready(bingo);

                function bingo()
                {
                    jQuery.ajax({
                        type: "POST",
                        data:  {varA: "123", varB: "456"},
                        success: function(data)
                        {
                            alert("POST to self is successful!");
                            $("#test").html(data);
                        }
                    });
                }
                </script>
                <?php
            }
            else
            {
                print_r($_POST['varA']);
                echo " - ";
                print_r($_POST['varB']);
            }
            ?>
    </head>
    <body>
        <input type="text" value="meow"/>
        <span id="test"></span>
    </body>
</html>
  • 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-05T22:33:28+00:00Added an answer on June 5, 2026 at 10:33 pm

    Omg that is so messy! Try the following code anyway:

    <?php 
    if (isset($_POST['varA']) && isset($_POST['varB'])) {
        print_r($_POST['varA']);
        echo " - ";
        print_r($_POST['varB']);
    } else {
    ?>
    <html>
        <head>
            <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
            <script type="text/javascript">
                $(document).ready(bingo);
    
                function bingo()
                {
                    jQuery.ajax({
                        type: "POST",
                        data:  {varA: "123", varB: "456", ajax: true},
                        success: function(data)
                        {
                            alert("POST to self is successful!");
                            $("#test").html(data);
                        }
                    });
                }
            </script>
        </head>
        <body>
            <input type="text" value="meow"/>
            <span id="test"></span>
        </body>
    </html>
    <?php
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a problem to using javascript for styling content? My website requires javascript.
I have a problem with css popup. I am hidden some content in span
Problem* Given some data (text) which has style applied to it with a loosely
as the title says I'm having the problem with content getting hidden while scrolling/dragging
I have a problem with flash content in IE7 being always over the menu
I’ve got this strange problem whereby the content within a scroll viewer increases in
The problem is that when the content loads it displays before the tag before
I have no problem to download the content of a specific URL. But I
Here's the problem: I have couple of pages which gets its content from a
When one creates web content in languages different than English the problem of search

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.