Reputation: 101
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.
Upvotes: 0
Views: 1216
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