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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:42:24+00:00 2026-05-19T22:42:24+00:00

My problem is the following: I have a real simple PHP file called writeSettings2.php

  • 0

My problem is the following:
I have a real simple PHP file called “writeSettings2.php” that has:

<?php 
    $text=$_GET["text"];
     setcookie("MG_FileTree_Opener_SelPath", $text);
?>

And then I have my PHP page, in which I have a JavaScript function called “makeChanges”, this function is called in a input type submit function and gets the combobox selected value and calls through xmlhttp the PHP function above like so:

<input type="submit" id="choice" value="Escolher" name="Esc" onClick="makeChanges()">

And the function “makeChanges” is like:

function makeChanges(  )
{
    var selObj = document.getElementById('opiniao');    
    var selIndex = selObj.selectedIndex;
    var str = selObj.options[selIndex].text;

    if (window.XMLHttpRequest)

    {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();

    }
    else
    {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
   xmlhttp.open("GET","writeSettings2.php?text="+str,true);
   xmlhttp.send(null);
   history.go(0);
}

Basically what I’m doing is use the JavaScript on the client fo call PHP function to rewrite the client cookie, and then refresh the page to get PHP to rewrite the page with the new info on the cookie.

This code works fine, but only for the fist 2 times! For instance my combox has item 1 and 2.
I load it and is item 1.
Change to item 2.
Change back to item 1.
Change to item 2 again —- FAILS never changes again, it always remains on 1.

Any suggestions?

  • 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-19T22:42:25+00:00Added an answer on May 19, 2026 at 10:42 pm

    Your browser is caching the ajax response. You need to add a random value to the ajax request, or put the no-cache header in the called page.
    You can change the javascript like so to fix it:

    var str = selObj.options[selIndex].text+'&random='+(new Date()).getTime();
    

    And/Or use the following php header:

    header("Cache-control: no-cache");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem: I have an HTML textbox ( <input type=text> )
I have the following problem using template instantiation [*]. file foo.h class Foo {
Has anyone encountered the following problem: I have IIS7 running on my computer. On
I have got the following problem since the server has safe mode turned on,
I have a real simple problem, but can't seem to figure it out. The
HI I have the following (apparently simple) problem: I have to install a simple
I have the following problem using subversion: I'm currently working on the trunk of
I have the following problem in my Data Structures and Problem Solving using Java
I have the following problem: I open the dialog, open the SIP keyboard to
I have the following problem. If I query values with a keyfigure which is

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.