pankaj bawdane
pankaj bawdane

Reputation: 101

How to get list items in response from ajax.request jquery

I am working on Asp.net MVC application which has function with a jQuery ajax call as below. I am getting a response as expected in data/result object.

It has multiple items in array.

How can check these items in if conditions. In my case i want check item at 0 index where RuleName = "License Denial"

I do not want to use for each loop, only wants to check first item in an array.

enter image description here

Upvotes: 0

Views: 1216

Answers (1)

Mikhail
Mikhail

Reputation: 9300

It looks like the "data" object is already an array. So, you can modify a condition in the following manner:

//if(data["items"][0]["RuleName"] == "License Denial") { ... }
if(data[0].RuleName === "License Denial") { ... }

Upvotes: 1

Related Questions