Home php How to parse json in jquery ajax?

How to parse json in jquery ajax?

by Shahriar Sagor

Today now in this post i would like to share with you How to parse json in jquery ajax. When we are working on php or .net etc and we are return data like json_encode($data) on the ajax request. But in the front side we get as like as a string on that time we need to parse json object and we can get them.

so, let’s see the example and then we can learn how to use:


var request = $.ajax({
  type: 'POST',
  dataType: 'json',
  url: 'http://www.mysite.com/getpostuser',
  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);

Read Also: How to Get Query Strings Value in Laravel?

Thanks for read. I hope it help you. For more you can follow us on facebook.


You may also like