This is a migrated thread and some comments may be shown as answers.

Failed to retrieve attributes in a Json response

1 Answer 72 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Nuo
Top achievements
Rank 1
Nuo asked on 21 Dec 2012, 08:36 AM
This is my first time using Kendo UI and I want to get a Json object from a Json file.

The Json string from Java controller looks like 
{"model": "Contract","rules": [{"initValues": ["5000"],"applyToFields" :["name","number"],"name": "MaxLengthRule"},{"name": "StartDateEndDateRule","applyToFields" :["startDate","endDate"]},{"name": "HierarchyValidationRule","applyToFields" :["hierarchy"]},{"name": "MasterContractValidationRule","applyToFields" :["hierarchy", "master"]},{"name": "JudgeDuplicatedRule","applyToFields" :["number"]},{"name": "ContractTypeRule","applyToFields" :["type"]}]}

And below is the script code. I want to get the rule attribute one by one. Now the alert with "Success!!!!!!!" is shown, 
 but I can only see some "undefined" in page after that. Could you help me on how to convert the Json string? Thanks a lot.


<script>
// document ready function
$(document).ready(function() {

var $validation = $("#validation");

// make an ajax call 
// to retrieve a JSON response 
$.ajax({
   // the url to the service
   url: "validation.do",
   contentType: "json",
   success: function(data) {
    alert("success!!!!!!!!!");
       $.each(data, function(index, item){
   $validation.append("<tr><td>" + item.model + "</td>" +
         "<td>" + item.rules + "</td></tr>");
       });
   }
});
});
</script>

Thanks
Best regards
Arnold

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 24 Dec 2012, 02:30 PM
Hello,

 Your code does not seem to include any of the Kendo UI widgets.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
General Discussions
Asked by
Nuo
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or