How to parse json in jquery ajax?

By Hardik Savani | April 5, 2016 | Category : PHP Javascript jQuery Ajax

When you are working php or .net etc and you return data like json_encode($data) on ajax request. but in front side you get like a string at that time you have to parse json object and get them. so, let's see example and learn how to use:


var request = $.ajax({

type: 'POST',

dataType: 'json',

url: '',

data: {token:obj['token'],postid: obj['postid']}


request.done(function(msg) {

msg = JSON.parse(msg);

msg.forEach(function(items) {

var e = "notify-"+items.userid;

io.sockets.emit(e, 1);



Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.