Hi,
I have a problem with the split()
function.
I get the error undefined but it dont know why :/
It is easier to explain with a working example: http://www.jsfiddle.net/V9Euk/415/
$(function start()
{
css('#div { font-color:#ff0000; border:1px solid #00ff00; }', '#div_2 { font-color:#ff0000; }', '#line2 { font-color:#00ffff; }');
});
function css(c0,c1,c2)
{
if(c0 != 'undefined')
{
c0_selector = c0.match(/^.*{/);
c0 = c0.replace(/^.*{/,'');
c0 = c0.replace(/}/,'');
c0_arr = c0.split(';');
values = new Array();
values[0] = new Array();
values[0][0] = c0_selector;
for (i = 1; i < c0_arr.length; i++)
{
values[0][i]= c0_arr[i].split(':');
}
}
if(c1 != 'undefined')
{
c1_selector = c1.match(/^.*{/);
c1 = c1.replace(/^.*{/,'');
c1 = c1.replace(/}/,'');
c1_arr = c1.split(';');
values[1] = new Array();
values[1][0] = c1_selector;
for (i = 1; i < c1_arr.length; i++)
{
values[1][i]= c1_arr[i].split(':');
}
}
$('#log').append(''+values[0][0]+'<br />');
$('#log').append(''+values[0][1][0]+'<br />');
$('#log').append(''+values[0][1][1]+'<br />');
$('#log').append('<hr />');
$('#log').append(''+values[1][0]+'<br />');
$('#log').append(''+values[1][1][0]+'<br />');
$('#log').append(''+values[1][1][1]+'<br />');
$.ajax({
url: 'test.php',
type: 'POST',
dataType: 'json',
data: $.toJSON(values),
contentType: 'application/json; charset=utf-8',
success: function() {
alert('success');
}
});
}
Thanks in advance! Peter