I have below array where i am appending values to string strOrderArr.
var strOrderArr = '';
$.each(uploadData, function (i, item) {
strOrderArr = strOrderArr + "{";
strOrderArr = strOrderArr + "'upld_contentlabel':" + "'" + item.label + "'" + ",";
strOrderArr = strOrderArr + "'upld_DocumentName':" + "'" + item.DocName + "'" + ",";
strOrderArr = strOrderArr + "'upld_docid':" + "'" + item.DocId + "'" + ",";
strOrderArr = strOrderArr + "'upld_contentvalue':" + "'" + item.value + "'";
strOrderArr = strOrderArr + "'upld_contentid':" + "'" + item.doc_contentid + "'";
//strOrderArr = strOrderArr + "'TotalCost':" + "'" + $(item).find("#lblTotalAmt_" + row).text() + "'";
strOrderArr = strOrderArr + "},";
});
I want to append one more value to strOrderArr from other array
$.each(Content, function (key, value) {
strOrderArr=strOrderArr+value.doc_contentid;
});
Is this possible? I tried as above but values are not appending. So where i going wrong? Thanks in advance.
1 Answer 1
var object1 = {
apple: 0,
banana: { weight: 52, price: 100 },
cherry: 97
};
// Assuming JSON.stringify - not available in IE<8
$( "#log" ).append( JSON.stringify( object1 ) );
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<div id="log"></div>
answered Aug 24, 2016 at 5:54
Kalu Singh Rao
1,6971 gold badge16 silver badges21 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js
JSON.stringify(OBJECT).. You have put so much efforts but they are not really needed...