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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:50:46+00:00 2026-05-22T12:50:46+00:00

I refer to this question: Javascript value to PHP with Jquery I tried with

  • 0

I refer to this question:
Javascript value to PHP with Jquery

I tried with below code in file named a.php:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript">
 var ms = 9000;
function test()
{
    $.ajax({ url: "a.php",
         data: {"test":ms},
         type: 'get',
         success: function(output) {
                      $('#testing').html(output);
                  }
    });
}
test();
</script>
<?php
$ms = $_GET["test"];
echo "I am getting below value:";
echo $ms;
?>

Then I point browser to http://localhost/learn/a.php but got error message & value of $ms is not shown as expected:

( ! ) Notice: Undefined index: test in
C:\wamp\www\learn\a.php on line 17

$ms = $_GET[“test”]; <– The line 17
in a.php

I tried another simpler code (b.php) below:

<script src="js/jquery.min.js"></script>
<script type="text/javascript">
 var ms = 3000;
 $.get("http://localhost/learn/b.php", { "test": ms } );
</script>
<?php
$ms = $_GET["test"];
echo $ms;
?>

Then I point browser to http://localhost/learn/b.php but got similar error message & no value of $ms displayed:

( ! ) Notice: Undefined index: test in
C:\wamp\www\learn\b.php on line 7
Below is code of line 7
$ms = $_GET[“test”];

Please advice. Thanks.

  • 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-22T12:50:47+00:00Added an answer on May 22, 2026 at 12:50 pm

    OK, looking at this code:

    <script src="js/jquery.min.js"></script>
    <script type="text/javascript">
     var ms = 3000;
     $.get("http://localhost/learn/b.php", { "test": ms } );
    </script>
    <?php
    $ms = $_GET["test"];
    echo $ms;
    ?>
    

    I’m presuming that this is all in one file. You have two bits of code in two different languages that are interpreted in different places. First, you have the Javascript at the top. This is not interpreted by your server. It is returned to the browser just as HTML is.

    Later, you have a piece of PHP. We’re still on the server, and haven’t sent anything to the browser yet. You look for a $_GET['test'] value. Your URL was http://localhost/learn/b.php: plainly there are no GET values in that URL, hence the error.

    When your code is sent to the browser, the browser sees the line $.get and does an AJAX request. This is another HTTP request. It does not modify the original request, so it doesn’t mitigate the error you received above. With this request, your browser will send http://localhost/learn/b.php?test=3000 to the server, and there won’t be an error. However, because you’re not doing anything with the response, you aren’t seeing the effects of this second request.

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

Sidebar

Related Questions

I want to add an iframe to the page. This iframe should refer to
I am working with a fairly complex third-party XSD format - XSDs refer to
I'm trying to write a script that can control different windows from different programs
I have a little problem. I want to pass two variables from PHP to
I want to create .dll with java jni. My .cpp file refers to an
As we all know, strings in .NET are immutable. (Well, not 100% totally immutable
I'm trying to create a client for a WCF service that I have hosted
In my iPad program I have an array which holds images. How can I
Considering the following data example : data ={ {a, b, c, d, e}, {1,
If I would like to create a model like Record which stores say a

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.