pigmentarts
asked on
more errors in IE jquerysqlbuilder-0.06.js
Having more errors with the following file in IE only. I get the following set of errors
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; MS-RTC LM 8; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; AskTB5.5)
Timestamp: Thu, 1 Apr 2010 15:34:41 UTC
Message: Expected identifier, string or number
Line: 106
Char: 13
Code: 0
jquerysqlbuilder-0.06.js
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; MS-RTC LM 8; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; AskTB5.5)
Timestamp: Thu, 1 Apr 2010 15:34:41 UTC
Message: Expected identifier, string or number
Line: 106
Char: 13
Code: 0
jquerysqlbuilder-0.06.js
ASKER
Trailing comma makes IE unhappy
Either add a dummy object to the end or remove the comma
Either add a dummy object to the end or remove the comma
ASKER
thanks for taking the time to look at this
from which part, line?
from which part, line?
ASKER
dummy object, could you give me an example, thanks
You JSON has a traling comma
Either remove it or add a {}, "" or [] to the end before the last } after wheredata[],
Either remove it or add a {}, "" or [] to the end before the last } after wheredata[],
e.g.
wheredata[]}
or
wheredata[],""}
If you cannot, then change
var j=eval('(' + jsonstr + ')');
to
jsonstr = jsonstr.substring(0,jsonst r.length-2 )+"}";
var j=eval('(' + jsonstr + ')');
wheredata[]}
or
wheredata[],""}
If you cannot, then change
var j=eval('(' + jsonstr + ')');
to
jsonstr = jsonstr.substring(0,jsonst
var j=eval('(' + jsonstr + ')');
ASKER
like this...
data=data+'wheredata:[';
$('span.sqlwhere').each(fu nction(){
var col_slot=$(this).find('a.a ddnewsqlwh ere').attr ('href').s ubstr(1);
var op_slot=$(this).find('a.ad dnewsqlwhe reoperator ').attr('h ref').subs tr(1);
var chain_slot=$(this).find('a .addnewsql wherechain ').attr('h ref').subs tr(1);
var col_value=$(this).find('sp an.addnews qlwhereval ue').html( );
var columndata= '{'+
'columnslot:'+col_slot+',' +
'opslot:'+op_slot+','+
'chainslot:'+chain_slot+', '+
'columnvalue:"'+col_value+ '",'+
'},';
data=data+columndata;
});
data=data+'][],';//close where data
data=data+'wheredata:[';
$('span.sqlwhere').each(fu
var col_slot=$(this).find('a.a
var op_slot=$(this).find('a.ad
var chain_slot=$(this).find('a
var col_value=$(this).find('sp
var columndata= '{'+
'columnslot:'+col_slot+','
'opslot:'+op_slot+','+
'chainslot:'+chain_slot+',
'columnvalue:"'+col_value+
'},';
data=data+columndata;
});
data=data+'][],';//close where data
ASKER
changing
var j=eval('(' + jsonstr + ')');
to
jsonstr = jsonstr.substring(0,jsonst r.length-2 )+"}";
var j=eval('(' + jsonstr + ')');
stops it working in firefox tho
var j=eval('(' + jsonstr + ')');
to
jsonstr = jsonstr.substring(0,jsonst
var j=eval('(' + jsonstr + ')');
stops it working in firefox tho
data=data+'][], <<<<<<<< still a trailing comma
Give me a sec
This works for me
<script>
var jsonstr = '{ reportid:9000, columndata: [{columnslot:19,columnas:"Advanced Credits"},],sortdata:[],groupdata:[],wheredata:[],}'
alert(jsonstr.substring(jsonstr.length-2))
if (jsonstr.lastIndexOf(',}')==jsonstr.length-2)
jsonstr = jsonstr.substring(0,jsonstr.length-2)+"}";
alert(jsonstr)
var j=eval('(' + jsonstr + ')');
</script>
oops
missing stuff
missing stuff
you have one more after
columnas:"Advanced Credits"}, <<<<<
columnas:"Advanced Credits"}, <<<<<
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks will have a play
alert(jsonstr)
var j=eval('(' + jsonstr + ')');
please on line 105