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

The Archive Base Latest Questions

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

<input id=’lightson’ class=buttonl type=button value=On /> <input id=’lightsoff’ class=buttonl type=button value=Off /> <p class=status2></p>

  • 0
<input id='lightson' class="buttonl" type="button" value="On" />
<input id='lightsoff'  class="buttonl" type="button" value="Off" />
<p class="status2"></p>

<script type="text/javascript">
$('#lightson').click( function(){
    $.get('http://<?php echo $_SESSION['ip']?>/?2', {}, callbacka());
    function callbacka(){
        $('.status2').load('status2.php').delay(3000).queue(function() {
            $(this).empty();
        });
    }
});

$( '#lightsoff' ).click( function () {
    $.get('http://<?php echo $_SESSION['ip']?>/?3', {}, callbackb());
    function callbackb(){
        $('.status2').load('status3.php').delay(3000).queue(function() {
            $(this).empty();
        });
    } 
});
</script>

When I click lightson, I want to load something in to my div and after three seconds to empty it. Also when I click lightsoff I want to load something else and after three seconds to empty it because both buttons use the same div.

This code works only once. When my page loads and I click one of two buttons (it doesn’t matter which button) it works, but if I click the other button, it loads the info in the div but doesn’t empty it.

My new code that works for the time is:

<input id='lightson' class="buttonl" type="button" value="On" />
<input id='lightsoff'  class="buttonl" type="button" value="Off" />
<p class="status2"></p>

<script type="text/javascript">
$('#lightson').click(function(){
    $.get('http://<?php echo $_SESSION['ip']?>/?2', {}, callbacka());
    function callbacka() {
        $('.status2').load('status2.php').delay(3000).queue(function(){
            $('.status2').empty().dequeue();
        });
    }
});

$('#lightsoff').click( function () {
    $.get('http://<?php echo $_SESSION['ip']?>/?3', {}, callbackb());
    function callbackb(){
       $('.status2').load('status3.php').delay(3000).queue(function() {
           $('.status2').empty().dequeue();
       });
    } 
});
</script>

Description for what I want with the above code: I have two button. When I click one of them I want to send the value “2” to a url and in the class status2 to load the content of status2.php and after 3secs to empty the class status2. And so on if I click the other button. I think the above code do the job.
If I remove the “()” from the callback when I click the button only send the value “2” and nothing else happens.

  • 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-28T16:25:27+00:00Added an answer on May 28, 2026 at 4:25 pm
    <script type="text/javascript">
        $( '#lightson' ).click( function () {
                $.get( "http://<?php echo $_SESSION['ip']?>/?2" );
                callbacka();
        } );
    
         function callbacka() {           
    
                    $( '.status2' ).load( 'status2.php' ).delay( 3000 ).queue( function() {
                        $('.status2').empty().dequeue();
                    });
    
        }
    
        $( '#lightsoff' ).click( function () {
                $.get( 'http://<?php echo $_SESSION['ip']?>/?3' );
                callbackb();
        } );
    
        function callbackb() {
    
                    $( '.status2' ).load( 'status3.php' ).delay( 3000 ).queue( function() {
                        $( '.status2' ).empty().dequeue();
                    });
    
        }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

input type=button name=colr value= Blue onclick=document.bgColor='#0000FF' Basically i have done buttons using javascipt to
$('input[type=checkbox]').unbind().click(function(e){ $(this).attr('checked', true) return false; }); I NEED to return false because I have
input type=text/radio/checkbox - can I treat them differently in my CSS? Other than by
Input: I have a LaTeX file, with plain text & math formulas. Desired output:
Input rz value In the head I have: Event.observe(window, 'load', function() { $$(input).each(function(field){ Event.observe(field,
Input: var str = 'text {{value1}} text {{value2}}text{{value1}}'; Regex: var result = str.match(/({{\S+}})+/ig); Output:
var input; // method 1 input = document.getElementById('address').value; alert(input) // method 2 eval('input =
My input string is: --> Job Title: Test text JobId: 56565-116503 City: San Diego
My input string is: <!--<clientHtml>--><br><br><br><b>Job Title:</b> Test text <br><b>JobId:</b> 56565-116503 <br><br><b>City:</b> San Diego <br><b>State:</b>
I input some text in <textarea></textarea> , I enter some line breaks, spaces,etc. purposely.

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.