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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:48:10+00:00 2026-05-21T08:48:10+00:00

This post relates to a previous that i posted but the question is different

  • 0

This post relates to a previous that i posted but the question is different now:
https://stackoverflow.com/questions/5671809/selection-on-change-set-session-not-working/5671816#5671816

When i select the select field in AJAX the session is set and the page is refreshed to display the value inside the session. How can i without a refresh have it where a handle like this

$("#output").something

check every second by sending an ajax request to ajax.php?action=checksessionShipping and that ajax file would return a true if the session is set or a false if not set. so once it detects that the session is set (btw, the session would be $_SESSION['shipping'] its on that other stack page.) it returns the value to a div.

  • 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-21T08:48:10+00:00Added an answer on May 21, 2026 at 8:48 am

    Keep in mind, this is the quick and dirty code. It should not be used in production as is because it’s not very secure or scalable. But, it’ll get you started:

    You could do something like this in your HTML:

    <div id="mydiv">
    
    </div><!-- END: #mydiv -->
    
    <script type="text/javascript" charset="utf-8">
    
        var myInterval = setInterval(function() {
    
            $.ajax({
              url: 'ajax.php?action=checksessionShipping',
              type: 'POST',
              dataType: 'json',
              data: {},
              complete: function(xhr, textStatus) {
                //called when complete
              },
              success: function(data, textStatus, xhr) {
    
                if (data.session_set == true)
                    $("#mydiv").html(data.shipping);
                    clearInterval(myInterval);
    
              },
              error: function(xhr, textStatus, errorThrown) {
                //called when there is an error
              }
            });
    
        }, 1000);
    
    </script>
    

    And something like this in your PHP:

    <?php
    
    session_start()
    $arrReturn = array('session_set' => FALSE);
    
    if (!empty($_SESSION['shipping'])) {
    
        $arrReturn['session_set'] = TRUE;
        $arrReturn['shipping'] = $_SESSION['shipping'];
    
    }
    
    echo json_encode($arrReturn);
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is related with one of my earlier questions.. Previous Post In there
This is related to a previous question , but it seems different enough to
I'm experiencing the same problem in this previous stackoverflow.com post . Specifically, I seem
Related to my previous post but its not a duplicate of that.Now I have
This relates to my previous post: jQuery .load Method causing page refresh AJAX I
This question is related to my previous post Image Processing Algorithm in Matlab in
This question is related to the previous post. How to save file and read
This question is related to a previous post . Is there something comparable to
This is a follow-up question related to my previous post . Below is a
I looked at previous post based on this but they do not relate. I

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.