Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6692057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:49:25+00:00 2026-05-26T05:49:25+00:00

I have a result like this { Errors : { Failure : { ShowAsPopup

  • 0

I have a result like this

{
    "Errors" : {
        "Failure" : {
            "ShowAsPopup"  : true,
            "ErrorMessage" :"Some Message.",
            "PopupTitle"   : null
        }
    },
    "IsValid" : false,
    "WarningMessage" : null,
    "SuccessMessage" : null
}

now if I do Errors.Failure.ShowAsPopup I get a value. What is expected. However I want to use index instead(if that is possible)

I tried

Errors[0].Failure.ShowAsPopup but this just gives me undefined. Ideal I would like to have it like Errors[0].[0].ShowAsPopup where I don’t have to specify the “Failure” but I might have to rethink that part.

I want a generic way to handle my errors. See some errors require a popup and some are just validation errors. So right now I have them all hardcoded and I am trying to get away from that. I rather just check if that error requires a popup or not.

So instead of

if(response.Errors.Failure) { // alert('hi')};
else if(response.Errors.Failure2 {// alert('hi2')}

and so on I would just have one if statement that could do the check.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:49:25+00:00Added an answer on May 26, 2026 at 5:49 am
    // check if any errors at all    
    if (response.Errors instanceof Object && (response.Errors !== {}))
    { 
        $.each(response.Errors, function(index, error){
            // for your example, index will be "Failure", error will be the Object inside
            if (error.ShowAsPopup) {
                // do your popup thing
            }
            else
            {
                // do whatever else
            }
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok I have some code that boils down to a pattern like this class
I have added a key-value pair in the action result like this: [HttpPost, Authorize]
i have sql statement like this SELECT DISTINCT results_sp_08.material_number FROM results_sp_08 INNER JOIN courses
I have a Linq to Entities query like this one: var results = from
I have a result from an SQL query that I would like to sort
I have a JSON result that contains numerous records. I'd like to show the
I have a problem that seems like its a result of a deadlock-situation. Whe
Into some view data i have put the result of an anonymous type: var
I have a user model like this: class User < ActiveRecord::Base validates :password, :presence
I have a simple SQL 'Select' query, and I'd like to dump the results

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.