javascript - retrieve Json Object's property returned from $.getJSON -


I'm unable to parse property from the JSON object. Since this is just a JSON object, I'm not sure if I'm $ Every needs to be done or I can get the properties directly in the form of data.d.property . Can anyone tell me how do I take about grabbing properties from this object?

I have it:

  jq (document) .ready (function () {var listDataURL} = ""; root root = getParameterByName ('RootFolder'); On the rootFolderID = getParameterByName ("id"); docSetTitle = root.substr (root.lastIndexOf ('/') + 1), listDataURL = "http: // SomeSite / sites / TestWF / _vti_bin / listdata.svc / resumeBank" "+ RootFolderID +"); // Jquery jQ.getJSON (listDataURL, function (data, status, jqXHR) {use the getJSON mehtod of console.log (jqXHR .responseText); // all items jQ.each (data .d.results, repeat through function (i, result) // // get item count for the latest set childItemCount = result.ItemChildCount; NumOfItemsApproved = result.ApprovalCounter;}); if (hair come Macken! == NumOfItems Approved) {Warning ("Ah ah! Approval Center has been received and needs to be fixed.");} If (ChildImemountCount === NumOfItems Approved) {Warning ("The approval mind looks good!" );}});});  

and JSON response is below, I'm trying to get the value of the acceptance count :

  {" D ": {" __metadata ": {" uri ":" http: //collaboration/sites/TestWF/_vti_bin/listdata.svc/ResumeBank (84) "," ETag ":" w / \ "12 \" ", "Type": "Microsoft.SharePoint.DataService.ResumeBankItem", "edit_media": "http: //collaboration/sites/TestWF/_vti_bin/listdata.svc/ResumeBank (84) / $ value", "media_src": "http : "Job Type", "Content Type": "Text / xml"}, "ID": 84, "ContentTipID": "0x0120D52000E387E9726C57FE40807A71CC05BEF45A005D5A666FE9576E42B629AF7CDB33F1B0", "ContentTip": "Job Application", "Created Or ":" / date (1413213951000) \ / "," CreatedBy ": {" __deferred ": {" uri ":" http: //collaboration/sites/TestWF/_vti_bin/listdata.svc/ResumeBank (84) / Created by "}}," CreatedById ": 1," Modified ":" \ / Date (1413561633000) \ / "," ModifiedBy ": {" __deferred ": {" uri ":" http: // collaboration / sites / TestWF /_vti_bin/listdata.svc/ResumeBank (84) / ModifiedBy "}}," ModifiedById ": 1," CopySource ": Null," Acceptance ":" 2 "," ApproverComments ": Null," Path ":" / Sites / TestWF / ResumeBank "," CheckedOutTo ": {" __deferred ": {" uri ":" http: // Collaboration /sites/TestWF/_vti_bin/listdata.svc/ResumeBank(84)/CheckedOutTo "}}," CheckedOutToId " True, "Owshiddenversion": 12, "Version": "1.0", "Title": "Tabitha Johnson", "Details": "Tablith Johnston", "Tabitha Johnson", "VirusStatus": "" "IsCurrentVersion" " : Null, "RoleAppliedFor": "Human Resources Assistant", "HiringDepartment": {"__deferred": {"uri": "http: //collaboration/sites/TestWF/_vti_bin/listdata.svc/ResumeBank (84) / HiringDepartment Null, "StartDate": "\ / Date (14131584000000) \ /", "ApprovalCounter": 0, "Education": Null, "Experience", "Hiring DepartmentValue": "Human Resources", "FirstRoundApprova L" : "ApproveEachDoc": Null, "ApproveDocSet1st": "2", "ApproveDocSet2nd": "2"}}  

The problem is that your $ Each () function.

  jq.each (data.d.results, function (i, results) {...}  

$.

Your array is the nested Jason object all in your "D" object. That's good.

Your callback is specifying a "key-value" pair function ( I, the result) where the loop returns to the {"approvalcontroller": "0"} object, i = "acceptance counter" and the result = "0." ... then < Code> results. Anything is about to throw an error.

Long Story short:

Change it:

  JQ.each (data.d.results, functions (results)) {// ... var count = Results.ApprovalCounter; // ...}  

and it should work ...

Alternatively:

You do not need to use $ "loop" to access the value from the "approval counter."

  data.d.ApprovalCounter  

... back "0."

Hope that helps!


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -