var sidebars = {};
var counter = 0;
// Loop through all already crated sidebars
$('.custom_dynamic_sidebars li').each(function(event) {
sidebars[counter] = $(this).text();
counter++;
});
var sidebars_string = JSON.stringify(sidebars);
but it gives me this string:
{\"0\":\"aa\",\"1\":\"bb\"}
does anyone know what am I doing wrong?
thx for your time
sidebars should be array?
var sidebars = [];
rvision_ said
sidebars should be array?var sidebars = [];
still doesn’t work…
I’m assuming that the string is output via PHP after an AJAX call?
The only thing I think it can be is PHP is adding in slashes due to a configuration on the server (magic_quotes_gpc). If you run stripslashes() on the JSON string before you output it or handle it with PHP and then it should be fine.
The actual PHP config that’s causing it is deprecated, however it’s still used on some servers for security reasons to ensure data is sanitised.
- Sold between 100 000 and 250 000 dollars
- Author had a File in an Envato Bundle
- Has been a member for 4-5 years
- Author had a Free File of the Month
- Won a Competition
- Author was Featured
- Item was Featured
- Bought between 10 and 49 items
Do you have prototype.js loaded in your page ? because it breaks JSON2
designedbydash said
I’m assuming that the string is output via PHP after an AJAX call?The only thing I think it can be is PHP is adding in slashes due to a configuration on the server (magic_quotes_gpc). If you run stripslashes() on the JSON string before you output it or handle it with PHP and then it should be fine.
The actual PHP config that’s causing it is deprecated, however it’s still used on some servers for security reasons to ensure data is sanitised.
Thank you so much man it works perfectly
You have saved me a lot of tyme
I was working on this issue for a all day but nothing. Thank you very much 
