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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:13:46+00:00 2026-06-05T03:13:46+00:00

function (data) { //add values based on activity type //data = JSON.parse(data); //alert(abc.Phone1); alert(data.myName)

  • 0
function (data) {
    //add values based on activity type
    //data = JSON.parse(data);
    //alert(abc.Phone1);

    alert(data.myName)

    alert(data.toString());
    if (activityType == "Phone") {
    }
    return;

},

As you can see this callback function of $.ajax taking JSON data from controller.

For example:

[{"name":"myName" ,"address": "myAddress" }]

In this case my first alert giving me undefined and second/third alert popup comes up with:

[{"name":"myName" ,"address": "myAddress" }]

How can I access value by name so that my first alert filled out with myName which is value of name?

  • 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-05T03:13:47+00:00Added an answer on June 5, 2026 at 3:13 am

    In stead of parsing JSON you can do like followng:

    $.ajax({
      ..
      dataType: 'json' // using json, jquery will make parse for  you
    });
    

    To access a property of your JSON do following:

    data[0].name;
    
    data[0].address;
    

    Why you need data[0] because data is an array, so to its content retrieve you need data[0] (first element), which gives you an object {"name":"myName" ,"address": "myAddress" }.

    And to access property of an object rule is:

    Object.property
    

    or sometimes

    Object["property"] // in some case
    

    So you need

    data[0].name and so on to get what you want.


    If you not

    set dataType: json then you need to parse them using $.parseJSON() and to retrieve data like above.

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

Sidebar

Related Questions

$('#post_form').submit(function() { $(#ajax_bar_loader).show(); $.ajax({ url: 'add.html', data: $('#post_form').serialize(), dataType: 'json', type: 'post', success: function(
I made this simple function to filter the data. I add the symbols that
$.ajax({ type: POST, url: add_secondary_interest.php, data: interest=ok, cache: false, success: function(html){ $('#interest_table tr:last').after(html); }
function stationMenu($scope){ $.ajax({ url: /users/station_names_ajax, type: POST, success: function(data){ $scope.phones = [ {name: Nexus
$(document).ready(function() { $('#content').html(''); $.ajax({ url:'data.json', dataType: json, success: function(data) { $('#content').append('<p>'+data.rank+'</p>'); } });}); In
$(function(){ $.getJSON('http://ws.audioscrobbler.com/2.0/?method=user.getweeklyartistchart&user=ElicitBelief&api_key=25135a535781328243f9e31968abc14&format=json', function(data) { alert(data) }); }); Firebug says: GET http://ws.audioscrobbler.com/2.0/?method=user.getweeklyartistchart&user=ElicitBelief&api_key=25135a535781328243f9e31968abc14&format=json 200 OK 144ms
$.getJSON(./data/revenue-item-data.php,{val:'val'},function(data){ $('#totalUnits').val(data[0].SUM(item_qty)); $('#totalAmounts').val(data[0].SUM(DISTINCT net_total)); }); Here is array I get for above code: [{SUM(item_qty):68,SUM(DISTINCT
Possible Duplicate: How to get JavaScript function data into a PHP variable i have
function checkSession(){ $.ajax({url: session.php, success: function(data){ if( data == 1){ var postFilen = 'msg.php';
I have a tooltip with data loaded from ajax: $('.show_tooltip').hover( function(){ $.post('getdata.php', function(data) {

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.