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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:59:51+00:00 2026-06-02T04:59:51+00:00

I have a javascript page that is supposed to send the username that the

  • 0

I have a javascript page that is supposed to send the username that the user enters to a php script on the server. The javascript page comes from http://192.168.1.4/login.html and it tries to access a php script at http://192.168.1.4/GetInfo.php. I think that I cannot access the username in the php script from the javascript page because of the same origin policy in firefox however, I’m not sure how to confirm this suspicion so please forgive me if I am wrong. I have only just begun to learn javscript and php. I was wondering if there is a different way to pass this information then. The code is below. Thanks!

The javascript:

<html>
    <head>
        <title>Login Page for SplitAuth</title>
    </head>
    <script language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
    <script language="Javascript">
        function getUsername()
        {
            var username = window.prompt('Please Type Your Username');
            var temp = document.getElementById('temp');
            temp.innerHTML = username;
            jQuery.ajax(
                {
                    type: "POST",
                    url:"GetInfo.php",
                    data: username,
                    success: function(msg)
                            {alert("data Saved: "+msg);}

                });//ends the jQuery send

        }//ends the GetUsername function
    </script>
    <body onLoad=getUsername()>
        <div id="temp">This will show text</div>
    <body>

</html>

The php script:

<?
$inFile="MyID.config.php";
$handle=fopen($inFile, 'r') or die ("No credentials could be gotten because the file MyID.config.php would not open.");

echo $_POST['msg'];

fclose($fh);

?>
  • 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-06-02T04:59:54+00:00Added an answer on June 2, 2026 at 4:59 am

    You should prepend your data: with “msg=”.

    ...
    data: "msg="+username,
    ...
    

    and the reason is that jQuery.ajax expects a query string or an object, which means that

    ...
    data: {msg: username},
    ...
    

    would also work.

    Take a look at the jQuery.ajax Documentation. Specifically the data-section

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

Sidebar

Related Questions

I have the following Javascript libraries loaded for my page. <script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js></script> <script
I have a <ul> that is populated with javascript after the initial page load.
I have a javascript page which checks an email and username, this works fine
I have a php page and i have some javascript code to have a
I coded a php page that displays information from a mysql database neatly into
I have written some javascript code that's supposed to put options into a select
I have an animated gif that's supposed to run until a page completes loading.
I have a PHP script (fetchData.php) that fetches some data and outputs it to
I have an html/css page that is supposed to use an html table layout
I have a HTML page that is supposed to display a calendar. There 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.