I have this already written code by someone else to add new value on UI.Its using Java Script, AJAX and Json which I am totally new to.
I am not getting how they are fetching the variable resultData
in done(function())
Code snippet is:
$.ajax(url, {
cache : false,
dataType: 'json',
data : {
depth: 10,
readSystemFields: true,
recordStates :'ACTIVE,PENDING'
}
}).done(function(resultData)
They are using it to get some values like:
$("#componentSectionFieldValue" + {{rowidObject}} + (i + "" +j) + "b2bFinancial" ).append( $('<a />').attr('href', 'mailto:' + mdm.entity360view.helperUtil.getData(**resultData**,
mdm.entity360view.ConfigContour.widgets.b2b.financal.section[i].field[j].coValue,
mdm.entity360view.ConfigContour.widgets.b2b.financal.section[i].field[j].defaultValue,
mdm.entity360view.ConfigContour.widgets.b2b.financal.section[i].field[j].defaultKey, mdm.entity360view.ConfigContour.widgets.b2b.financal.section[i].field[j].defaultKeyValue,
mdm.entity360view.ConfigContour.widgets.b2b.financal.section[i].field[j].coFieldValues,
mdm.entity360view.ConfigContour.widgets.b2b.financal.section[i].field[j].concatenateWith,
mdm.entity360view.ConfigContour.widgets.b2b.financal.section[i].field[j].getStrategy) ).text(mdm.entity360view.helperUtil.getData(resultData,
mdm.entity360view.ConfigContour.widgets.b2b.financal.section[i].field[j].coValue,
mdm.entity360view.ConfigContour.widgets.b2b.financal.section[i].field[j].defaultValue,
mdm.entity360view.ConfigContour.widgets.b2b.financal.section[i].field[j].defaultKey,
mdm.entity360view.ConfigContour.widgets.b2b.financal.section[i].field[j].defaultKeyValue,
mdm.entity360view.ConfigContour.widgets.b2b.financal.section[i].field[j].coFieldValues,
mdm.entity360view.ConfigContour.widgets.b2b.financal.section[i].field[j].concatenateWith,
mdm.entity360view.ConfigContour.widgets.b2b.financal.section[i].field[j].getStrategy)) );
This is a very good resource to see how done works with jquery ajax.
jqXHR.done(function( data, textStatus, jqXHR ) {})
; An alternative construct to the success callback option, refer to deferred.done() for implementation details.
Then go through the documentation on done().
Since the jQuery.get method returns a jqXHR object, which is derived from a Deferred object, we can attach a success callback using the .done() method.
$.get( "test.php" ).done(function() { alert( "$.get succeeded" ); });
Hope this helps to get you started.