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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:41:37+00:00 2026-06-15T14:41:37+00:00

I have been stuck with this bug for a long time now, and i

  • 0

I have been stuck with this bug for a long time now, and i simply have to little knowledge of php to solve it. So i pray for your help.

My problem is, that after i make a post (or ajax) request to my site, the GET request disappears and thus leaving me a NULL object (since i create my object from that id).

I have made some tests, and the problem is at the GET is NULL in the response i got from the POST. And this doesn’t happen if i forget about the get and just initiates the id as a random number.

Here are some parts of my code where i think the problem is:

First is the php with my GET:

require 'php/functions.php';

    if (isset($_GET['id'])) {

    $id = $_GET['id'];  

    // $id = 5;

    try {
    $bar = getBarById($id);
    } catch (exception $e) {
        exit;
    }

After this i output some date from the object and it works all fine, the GET is being initiated here.

Now. When i make my ajax (i tried regular POST also) request, the status response from POST is OK, but after that nothing happens and det response says that my GET request is NULL.

The JS:

<script language="javascript" type="text/javascript">
function save(value) {
$.ajax({
type: "POST",
url: "barpage.php",
data: { save_sum: value }
}).done(function(msg) {
    msg.preventDefault();
 alert( msg );
});
}

Just for the record. It is the “msg” response from ajax that tells me that nothing happens. and that “$id” is NULL.

What am i doing wrong?

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-06-15T14:41:40+00:00Added an answer on June 15, 2026 at 2:41 pm

    Here’s the deal:

    Your AJAX request is doing a POST request, thus the GET array is not being filled, because, well, you’re doing a POST request instead of a GET one. A quick fix would be to send the Id as part of the ajax request and on your php file, ask for it like this:

    $id = isset($_GET['id']) ? $_GET['id'] : null;
    if($id == null) { 
       $id = isset($_POST['id']) ? $_POST['id'] : null;
    }
    

    An alternative solution

    $id = null;
    if($_SERVER['REQUEST_METHOD'] == "GET") {
       $id = isset($_GET['id']) ? $_GET['id'] : null;
    }
    if($_SERVER['REQUEST_METHOD'] == "POST") {
       $id = isset($_POST['id']) ? $_POST['id'] : null;
    }
    

    An even better solution (from comment bellow)

    $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
    

    Hope that helps!

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

Sidebar

Related Questions

I have now been stuck at this for some time so I though to
I have been stuck for a long time on this simple but obtuse message
I have been stuck with this problem for quite some time now and i
I have been stuck on this for a while now and I cannot seem
so i have been stuck with this issue for 3 weeks now and i
I have been stuck on this for days, and was wondering if anyone had
I have been stuck on this for a while. i have tried and I
I have been stuck on this and don't really know how to go about
I have been stuck on this silly if statement, whatever i do, I cannot
i know this is basic but somehow i have been stuck here for some

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.