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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:37:43+00:00 2026-06-18T03:37:43+00:00

How come i can’t return id using data[0].id? $(document).ready(function(){ $.ajax({ type: ‘POST’, dataType: json,

  • 0

How come i can’t return id using data[0].id?

    $(document).ready(function(){   
$.ajax({
  type: 'POST',     
  dataType: "json",
  url: '<?php echo matry::base_to('tests/map_it');?>',
  success: function (data) 
  {
     alert(data[0])
    $('#alerts').html(data);
    data[0].id

  }

  });
});

Here’s the alert that’s returning.

    {"id":19385,"first":"RLY","last":"MAZI",
    "trainer_address1":"19 NE 13H CRT",
    "trainer_address2":null,"CITY":"MII","STATE":"AL",
    "trainer_zip":"33333","trainer_phone":"(721)222-4444","trainer_fax":null,
    "trainer_cell":"(213)213-  2133","website_trainer_id":115,"trainer_email":"MO@gmail.COM",
"trainer_group":"","inactive":null}

Any help would be greatly appreciated.

EDIT
Here is the php that returns that json:

$mapit = sql::results("Select * from event.ACS.trainer where inactive is null or inactive=0");
foreach ($mapit as $row)
{
    $return[] = json_encode($row, JSON_FORCE_OBJECT);
}
echo json_encode($return);

I have to loop through and encode each row because, otherwise, the ajax function doesn’t think there is json that is returned (and my data var is empty)

  • 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-18T03:37:44+00:00Added an answer on June 18, 2026 at 3:37 am

    data[0] looks like JSON, so you’ll have to parse it before you can use it as an object. e.g. $.parseJSON(data[0]).id

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

Sidebar

Related Questions

How come I can't use normalizer function? I am using it exactly as I
How come I can post correctly using https://developers.facebook.com/tools/explorer/ with this url: https://graph.facebook.com/me/og.likes?object=http://guidepal.com/escape/30?access_token=xxx where xxx
I'm trying to write a function that takes multiple arguments, which can come either
How come I can say: var myFunction = function() { setTimeout(myFunction, 1000); } myFunction();
How come I can't return an element_text() > ifelse(TRUE,element_text(size=20),element_text(size=10)) [[1]] NULL but I can
By using the wizard, and selecting Office 2007 style, you can come up with
I am wondering how come I can reach inner class directly from outer type
Using GScript for example, is there any harm that can come to a phone
I can come up only with serialization, using of WCF, etc. But is there
How come I can't instantiate an object of type Foo with above constructor? I

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.