473,396 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

display json data using AJAX

Hi,

my aim is to display the content of my json data i receive from my php file.

php is sending :

PHP--->

$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);

echo json_encode($arr);

<---


AJAX--->
ajax is receiving "data" and displaying : data = {"a":1,"b":2,"c":3,"d":4,"e":5}

now, how can is display for exemple the item "c" to get "3" something like :

alert(' a = "+..--->what must i put here<-----.);

i tried : date[2], but it is not working ! is says : UNDEFINED


thx for your help


Boris
Dec 28 '11 #1
2 3023
SOLVED

------->

solution :

var obj = jQuery.parseJSON(data);

alert( obj.a);


thx to all for you help !
Dec 28 '11 #2
Dormilich
8,658 Expert Mod 8TB
note: associative arrays in PHP are plain objects in JS (because JS arrays are *always* numerically indexed)
Dec 29 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Daman | last post by:
Hi, I am currently facing difficulty displaying chinese, japanese, russian etc. characters. I am using VB 6 and ADO to query the DB2 Version 7.2 unicode database (UTF-8). The resultset that...
3
by: Fungi2003 | last post by:
I am binding a datagrid to a dataset but there are some columns I don't want show in the dataset, what is the easiest way of removing these columns yet still binding to that dataset?
1
by: dan.goyette | last post by:
I'm fairly new to using AJAX. I'm currently developing a data grid application in coldfusion, using AJAX for paging/filter/sorting updates to the grid. So far I've just been returning raw html, and...
1
by: pyssarma | last post by:
hi, I am new to mysql (4.0) php combination. Trying to display mysql table data using php. I have tested connection successfully but could not display table data using php. What could be the...
3
by: xhe | last post by:
I found Jason is a very handy data format for client/server communication. But I just met a problem as follows: I want to read the data replied from server in Jason format, the reply is like...
1
by: ghjk | last post by:
I'm developing web application using php. In there i want to refresh one of my table which is having mysql data, using ajax. How can I do that? I didn't know anything about ajax and could you please...
2
pradeepjain
by: pradeepjain | last post by:
i have a page post2.php which prints the json array like { page: 1, total: 239, rows: }, {id:'238',cell:}, {id:'237',cell:}, {id:'236',cell:}, {id:'235',cell:},
0
by: BaseballGraphs | last post by:
Hello, I am trying to use Ajax in order to improve the speed of my website. I am trying to pull data from a dynamic page and insert the data onto the current page. There are 3 three things I am...
2
irfanmodan
by: irfanmodan | last post by:
Hello Everyone... i have one issue.please help me My name {is} and.i {am} a php {developer}..how to display value within brecket '{.}'... also that value will be used to fetch value from the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.