Bhargav mullakuru Ответов: 1

Мне нужно получить имена из json на основе обозначения= "менеджер".... используя jquery....


«Сотрудники»: [{«Address1»: null, «Address2»: null, «City»: «Banglore», «ContractDocPath»: null, «Designation»: «Field Executive», «Email»: «adminhq @ gmail. com "," EmployeeID ": null," FEZone ": null," FirstName ":" Admin "," IDProof ": null," IsActive ":" True "," IsTermConditionAccepted ": null," LastName ": null," MiddleName ": null," OfficePhone ": null," PersonalPhone ": null," PhoneNumber ": null," PostalCode ":" 560078 "," ProfileImage ": null," RoleID ":" 1 "," RoleName ":" Admin "," State ":" KA "," TypeName ":" Admin "," UserID ": 1," UserType ":" 1 "}, {" Address1 ": null," Address2 ": null," City " : "Banglore", "ContractDocPath": null, "Назначение": "Менеджер", "Электронная почта": "adminhq@gmail.com", "EmployeeID": null, "FEZone": null, "FirstName": "Admin" , «IDProof»: null, «IsActive»: «True», «IsTermConditionAccepted»: null, «LastName»: null, «MiddleName»: null, «OfficePhone»: null, «PersonalPhone»: null, «PhoneNumber»: null , «PostalCode»: «560078», «ProfileImage»: null, «RoleID»: «1», «RoleName»: «Admin», «State»: «KA», «TypeName»: «Admin», «UserID» : 1, "UserType": "1"}]

Что я уже пробовал:

пожалуйста, помогите мне.... я пробовал много methods...it больше данных json нужно сортировать и отображать на основе значения обозначения...

1 Ответов

Рейтинг:
9

Mohtshm Zubair

Я поставил данные ur как


var data = { "Employees":[{"Address1":null,"Address2":null,"City":"Banglore","ContractDocPath":null,"Designation":"Field Executive","Email":"adminhq@gmail.com","EmployeeID":null,"FEZone":null,"FirstName":"Admin","IDProof":null,"IsActive":"True","IsTermConditionAccepted":null,"LastName":null,"MiddleName":null,"OfficePhone":null,"PersonalPhone":null,"PhoneNumber":null,"PostalCode":"560078","ProfileImage":null,"RoleID":"1","RoleName":"Admin","State":"KA","TypeName":"Admin","UserID":1,"UserType":"1"},{"Address1":null,"Address2":null,"City":"Banglore","ContractDocPath":null,"Designation":"Manager","Email":"adminhq@gmail.com","EmployeeID":null,"FEZone":null,"FirstName":"Admin","IDProof":null,"IsActive":"True","IsTermConditionAccepted":null,"LastName":null,"MiddleName":null,"OfficePhone":null,"PersonalPhone":null,"PhoneNumber":null,"PostalCode":"560078","ProfileImage":null,"RoleID":"1","RoleName":"Admin","State":"KA","TypeName":"Admin","UserID":1,"UserType":"1"}
]}; 


    var returnedData = $.grep(data.Employees, function(element, index){
          return element.Designation == 'Manager';
    });
    
    alert(returnedData[0].UserID + "  " + returnedData[0].Designation); 
    alert(returnedData[returnedData.length-1].UserID + "  " + returnedData[returnedData.length-1].Designation); 



Пожалуйста, проверьте это и отметьте этот ответ как решенный!!!