Mr.Kiran Mr.Kiran - 1 year ago 67
Ajax Question

Handling ajax success response

PHP: lockState.php

require '../dbconn.php';
$query = mysql_query("select id, lockState,name from register_db where Id=1");
$items = array();
while ($row = mysql_fetch_object($query)) {
array_push($items, $row);
echo json_encode($items);

Result from query

[{"id":"1","lockState":"No","name":"Local Application"}]


type: "POST",
url: "feed/lockState.php",
data: ({id: 1}),
cache: false,
success: function (response) {
alert(JSON.stringify(response)); // [{"id":"1","lockState":"No","name":"Local Application"}]
alert(; //***undefined***
if('Local Application'){
error: function () {
alert("Oops..!! Something wrong!);


I'm totally lost where I'm doing wrong in using 'Success' response. Even I tried to
and tried to access the key:value, but still same
. Please help.

Answer Source

response[0].name will help you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download