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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:58:53+00:00 2026-05-27T01:58:53+00:00

Three days had passed and still having problems to get this things work. This

  • 0

Three days had passed and still having problems to get this things work.
This AJAX Call on my js file seems working when it comes to sending JSON data:

 var _lname = $('#ptLastName').val();
 var _fname = $('#ptFirstName').val();
 var _mname = $('#ptMiddleName').val();
 var _gender = $('#ptGender').val();
 var _bday = $('input[name="birthdate"]').val(); // $('#ptBirthDate').val();
 var _ssn = $('#ptSSN').val();

 $.ajax({
          type: "POST",
          url: ".././CheckPerson.php",
          data: "{'lastName':'" + _lname + "','firstName':'" + _fname + "','middleName':'" + _mname + "'}",
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: function (response) {
          var res = response.d;
          if (res == true) {
               jAlert('Person Name already exists!', 'Error');
               return;
          } 
})

but in my PHP file:

$lastname = json_decode($_POST['lastName']);
$firstname = json_decode($_POST['firstName']);
$middlename = json_decode($_POST['middleName']);
$response = array();

mysql_connect ("*****", "****") or die ('Error: ' . mysql_error());
mysql_select_db ("********");

$query = "SELECT Lastname, Firstname, MiddleName FROM tbl_people WHERE Lastname = '$lastname' || Firstname = '$firstname' || MiddleName = '$middlename'";

$result = mysql_query($query);

$row = mysql_fetch_array($result);

    if ($row) {     
        $response = json_encode(array('d' => true, 'test' => $lastname)); 
    }
    else { 
    $response = json_encode(array('d' => false, 'test' => $lastname));
    }
echo $response;
print json_encode($_POST);

some error from firebug console says:

<br />
<b>Notice</b>:  Undefined index: lastName in <b>C:\xampp\htdocs\..\CheckPerson.php</b> on line <b>2</b><br />
<br />
<b>Notice</b>:  Undefined index: firstName in <b>C:\xampp\htdocs\..\CheckPerson.php</b> on line <b>3</b><br />
<br />
<b>Notice</b>:  Undefined index: middleName in <b>C:\xampp\htdocs\..\CheckPerson.php</b> on line <b>4</b><br />
{"d":false,"test":null}[]

i believe that json_decode() is working fine in my php file but $_POST[''] can’t recognize my posted data from my ajax call w/c variables had been declared:

data: "{'lastName':'" + _lname + "','firstName':'" + _fname + "','middleName':'" + _mname + "'}",

I believe I am doing right with my codes seems i had read many questions here and done what they had said but don’t know why the error occurred.
Is there any problem/bug you had seen? please tell me.

  • 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-27T01:58:54+00:00Added an answer on May 27, 2026 at 1:58 am

    Can you see the ajax request data using the firebug console?

    You cannot get the lastname, firstname from $_POST. It’s inside the json string. First, you have to get the data using

     $data = $_POST['data'] or $_REQUEST['data']
    

    Then, decode the $data using json_decode() and access your attributes.

    json_decode($data);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried for three days now and gotten nowhere on this.... I absolutely
Every day we get a flat text file. Some days there are lines in
I am using jQuery-1.4.2 with CakePHP and a few days ago I had this
Alright I've spent a good three days trying this, here's the scenario: I want
I have had this for a couple of days now. I have a simple
Had this question on Serverfault for a few days with no luck. I've run
I spent the last three days working on the collection _ select form helper
I will participate a modeling competition, which spends three days. I need a language
Given three tables Dates(date aDate, doUse boolean), Days(rangeId int, day int, qty int) and
A couple of days ago I had to investigate a problem where my application

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.