I'm using a mysql query on my database and building a row array using fetch_array() function in my php script and converted it into json. Now in my ajax success code in can see the row in my console log as bellow
"{"0":"84","id":"84","1":"btv","news_name":"btv","2":"BTV","news_title":"BTV","3":"Bangladesh Televesion","news_description":"Bangladesh Televesion","4":"/management/template/img/default_logo.png","news_logo":"/management/template/img/default_logo.png","5":"Dhaka, Bangladesh","news_address":"Dhaka, Bangladesh","6":"free","subs_status":"free","7":"33","newscreatedbyID":"33","8":"2014-08-21","newscreateddate":"2014-08-21","9":null,"sponsored":null,"10":"0","protectstatus":"0","11":"0","approved":"0"}"
My js success function is as follow:
$.ajax({
url: "/function/news_user_page.php",
type: "POST",
data: {news_name:'84'},
success:function(data, textStatus, jqXHR)
{
$("#test").html(data.news_title);
console.log(data);
},
error: function(jqXHR, textStatus, errorThrown)
{
//if fails
}
})
I can see the whole data in my consol log but in my html element named test the news_title is now showing. the data.news_title is not working. How to access my converted json data? i am bit confused.