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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:56:09+00:00 2026-05-26T16:56:09+00:00

Ok this code seems to be working now (ajax getting the current selection) .

  • 0

Ok this code seems to be working now (ajax getting the current selection) . But i now have another problem. When i use php $_GET method (for later database search), the output isnt just dropdown chosen word, but also generates another dropdown menu. There is also WAMP error – undefinex index for GET.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $("#select").change(function(){
        $.ajax({
                url: "test.php?selected=" +$(this).val(),
                success:function(data){
                    $("#results").html(data);
                }
            }
        )
    })
});
</script>
<select id="select">
<option> something </option>
<option> something2 </option>
<option> something3 </option>
</select>

<?php

echo $_GET['selected'];

?>

<div id="results"></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-26T16:56:09+00:00Added an answer on May 26, 2026 at 4:56 pm

    The problem is arising because you’re self-referencing in the ajax call without accounting for the postback. Also the initial page load will throw an undefined index error because the selected key does not exist in the $_GET collection.

    At the top of your test.php file:

    <?php
        if(array_key_exists('selected', $_GET))
        {
            echo $_GET['selected'];
            die();
        }
    ?>
    

    Then remove your echo later on in your example.

    Note that this is only to make your example work and show why it failed. Not to give a well-formed example of an AJAX request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is an erlang problem, it seems. I have this code to test the
I have absolutely no idea why this is happening but the following code seems
I have 2 questions on this My code always seems to hit a 401
First check out this code. I seems like it should work for me, but
I have the following code in a shell script. This only seems to work
I have some code, int count = 0; list.ForEach(i => i.SomeFunction(count++)); This seems to
hellp guys, I've been working on ajax recently, and I have a problem in
This seems like a simple thing, but my brain doesn't seem to be working
EDIT: I have now discovered the problem is with my WCF service getting dirty
I now have a working JSON formatted file from my PHP scripts. The next

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.