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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:29:20+00:00 2026-06-13T20:29:20+00:00

I have the following code in my script file: $.ajax({ url: server.php?saveEvent, data: myEvent=

  • 0

I have the following code in my script file:

$.ajax({
    url: "server.php?saveEvent",
    data: "myEvent=" + JSON.stringify(myEvent),
    dataType: "json",
    type: "post",
    success: function (data) {
        if (data) {
            $("#log").append("<br />Evenement saved.");
        }
    }
});

In server.php I retrieve the variable using:

if (isset($_GET['saveEvent'])) {
    if (isset($_POST['myEvent'])) {
        $firephp->log(gettype($_POST['myEvent']));
        $myEvent = json_decode($_POST['myEvent'], true);
    }
}

When I tested this on my localhost, everything went fine. Unfortunately, after deployment,
$myEvent
was empty.

Using firephp, I tested what was in the variable, and I looked at the headers being sent. The object was sent to the server, but still somehow php see’s it as being an empty variable.

Any ideas on how this is possible? Is it a php version or json issue?

EDIT: PHP ver= 5.2.17 / json enabled

EDIT2: Changing te url to ?saveEvent=1 didnt change anything

Edit3: I realize making a get and post is a bit strange, I’ll try changing that, but get/post shouldn’t be a problem I think

  • 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-13T20:29:21+00:00Added an answer on June 13, 2026 at 8:29 pm

    Your uri contains a GET parameter, saveEvent. You’re checking for POST data only

    try checking this: $_GET['saveEvent']

    Even so, that parameter hasn’t got a value assigned to it, perhaps change the url to ?saveEvent=1.
    There’s also no reason for you to use 2 if statements:

    if (isset($_GET['saveEvent'] && isset($_POST['myEvent']))
    {
        //do stuff
    }
    

    Since it seems there’s more going on than just the GET vs. POST issue, you might want to add an ampersand (&) at the end of your url: look at your console, the XHR request just pastes the POST parameters at the end of your url, so the uri will look like either one of the following urls:

    server.php?saveEvent=truemyEvent=foo
    server.php?saveEvent=1myEvent=foo
    server.php?saveEventmyEvent=foo
    //or
    server.php?saveEvent=1?myEvent=foo
    

    Whereas, what you need is:

        server.php?saveEvent=1&myEvent=foo&something=else
    

    Basically, stick to 1 method, either POST or GET, and make sure that the various parameters are separated as they’re supposed to be separated.
    I’m not sure if this is the issue, but try var_dump-ing the $_REQUEST super-global, along with $_GET, $_POST and what have you…

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

Sidebar

Related Questions

I have the following PHP script being called by AJAX: <?php // file /ajax/loopback.php
I have the following code in a PHP file called via Ajax (note -
I have MVC3 project & Valums file uploader . The code is following <script
I have the following code validation php script: if(empty($_POST['captcha_code'])) { $error = 1; $code[3]
I have the following code in the front end <asp:Content ID=Content1 ContentPlaceHolderID=cphMain runat=server> <script
My jQuery code (using ajax) request's data from a local php script (pgiproxy.php). This
I have the following code in action script 3: async.addResponder(new Responder(result, defaultFaultHandler)); result is
I have the following code: <script> $(document).ready(function() { $('.toggle_section').click(function(e){ parent = $(e.target).closest(div) objChild =
I have the following code: <fx:Script> <![CDATA[ import shared.GlobalsManager; import app.Globals; protected var globals:Globals=GlobalsManager.getGlobals();
I have the following code that works fine in IE: <HTML> <BODY> <script language=JavaScript>

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.