I form a string
for (var i = 0; i < json_length; i++) { tmppie_traffic_source+='{"title" : '+'"'+json.data[i].name+ '","litres" : '+json.data[i].visits+'},'; } How to make it so that in the last iteration of the loop by the end did not put a comma?
json.data[i].visits+'},'; Now I solve the problem through replace , but I think it can be otherwise