[jQuery] How to load form fields with JSON
I'm noob in Jquery, can you show me better way how to load form with
JSON - plugin or anything else...
============================================================================
I have JSON
[{"Id":5},{"Instance":"Hello there Franky"}]
and I want to load form where key of JSON object is ID attribute of
the field.
I came up with this:
<script>
function loadform(formid, url){
$.getJSON(url, function(json){
var forma = $('#'+formid);
for (var i = 0; i < json.length; i++) {
for ( key in json[i]){
var value = eval('json[i].'+key);
$("#"+key, forma).attr({value:value});
}
}
});
}
</script>