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

  • Home
  • SEARCH
  • 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 9268853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:57:50+00:00 2026-06-18T14:57:50+00:00

I have an AJAX Request, that essentially queries a database then posts the data

  • 0

I have an AJAX Request, that essentially queries a database then posts the data back to the JS, however I can’t print individual bits of data.

My code is as follows:

$.ajax({
            type: 'POST',
            url: '_process/offerrespres.php',
            dataType: 'json',
            data: {
                msgid: msgid,
                usrid: usrid
            },
            success: function(){
                console.log(JSON.parse(data.pro_name));
                console.log(data.accept_decline);
            }
        });

The PHP:

<?php
include_once 'connect.php';
if ($_POST) {
$msgid = mysql_escape_string($_POST['msgid']);
$usrid = mysql_escape_string($_POST['usrid']);  
$getmsgq = mysql_query("SELECT * FROM booking_requests WHERE receiver_id = '$usrid' AND msg_id = '$msgid'");
$getmsg_info = mysql_fetch_array($getmsgq); 
$data['success'] = true;
$data['date_sent'] = $getmsg_info['date_sent'];
$data['pro_name'] = $getmsg_info['pro_name'];
$data['accept_decline'] = $getmsg_info['accept_decline'];
}
header("Content-Type: application/json", true);
echo json_encode($data);
mysql_close();
?>

As you can see I’ve tried this:

console.log(JSON.parse(data.pro_name));
console.log(data.accept_decline);

the error in the console says “data not defined”. The output from the PHP file is correct and how it should be, I just can’t print one single piece of data.

  • 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-18T14:57:51+00:00Added an answer on June 18, 2026 at 2:57 pm

    Your callback function isn’t accepting the return data as an argument

    The line that reads success: function(){ should be success: function(data){

    Also, the true isn’t needed in your call to header("Content-Type: application/json", true);. The default action of this function is to replace headers, so true is already implied. That argument is only necessary if you don’t want to replace the previous Content-Type. Makes no difference to your code, just a tip.

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

Sidebar

Related Questions

I have jQuery Ajax request that sends data to a PHP page that then
I have an Ajax request that can return more than one valid value, so
I have an ajax request that sends data to my controller, but i want
I have an $.ajax() request that queries currency exchange rate information from another web
I have an Ajax request that sends some data to a page and expects
I have an ajax request that gets back some html <div id=test> </div> in
I have an AJAX request that fetches some info from a SQL database in
I have an ajax POST request that is supposed to be submitting data to
I have AJAX request that takes data from remote file and displays in a
I have ajax request that do 3 missions: Save Model (DB) Send Email Give

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.