I am working on some website and use JSON. My problem is the JSON.parse method, I use it to send a simple array and add values ββto the array. And I always get an extra element at the end that we are just commas. here is a simplified code:
responseText = '["dummy1", "dummy2", "dummy3", "dummy4"]'; var clientList=[]; try { JSON.parse(responseText, function(key, val){clientList.push(val)}); } catch (e) { alert('no'); } alert(clientList.length);
At first in IE it doesnβt work at all (exception thrown).
As a result of the second chrome, the result of clientList is an array of 5 lines, and the last is ",,".
Why does this added value exist? Can I get rid of it (just without popping the array at the end)? And what is wrong with IE?
Ramzi kahil
source share