I am sorry if it is a simple problem for you.But i am really struggling with this problem
In our application we have plenty of ajax calls in each and every page. We are using jQuery ajax. Presently what we are doing is
When we get the result from like myresults
, we are passing to a function populate
where we are building the result.
function populate(myresults)
{
var str='<table>';
for(var i in myresults){
str+='<tr>';
str+=myresults[i].name;
str+='</tr>';
}
str+='</table>';
$('#divId').html(str);
}
Not exactly we are building tables in all places. The code is working perfectly, but I think writing of code like this is not the right approach. How can I can beautify my code. I can use jQuery or javascript.