PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, July 25, 2022

[FIXED] How to convert json to plain text?

 July 25, 2022     javascript, jquery, json     No comments   

Issue

How to convert JSON to plain text?

{"Days":["is not a number"]} to Days is not a number.

Here is the code:

$('.best_in_place').bind("ajax:error", function(jqXHR,error, errorThrown) {
  alert(error.responseText);
});

Solution

Convert the response into JSON object and parse its key-value pair

var error = JSON.parse( error.responseText );
for( var name in error ) {
    console.log( name + " " + error[ name ] ); // Days is not a number
}


Answered By - Ravi K Thapliyal
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing