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
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