You can prevent eval() in your code with : document[applet_name].Loadinline(sdf)
Paul
Le 7 févr. 2013 à 17:42, Otis Rothenberger a écrit :
> Quentin,
>
> I'm not fully following your use of pipes, but I think one error is the
> following:
>
> sdf=sdf.replace(/\|/g,"\n|");
>
> I think you need //n not just /n.
>
> Otis
>
> --
> Otis Rothenberger
> o...@chemagic.com
> http://chemagic.com
>
>
>
>
> On Feb 7, 2013, at 11:31 AM, Quentin Delettre wrote:
>
>> Dear jmol user list,
>>
>> I have a problem.
>>
>> In my project, i retrieve molecule in sdf from my database via ajax
>> calls + php. The molecule data is returned as json.
>>
>> I am doing this because i want to load the molecules only if they are in
>> the browser view, like lazy loading. Ajax calls are made, no problem
>> here and the visibility question is already solved.
>>
>> So i have the possible case to have multiple applets loaded without
>> content and then when they are displayed to the user, the molecule(s)
>> has to be loaded.
>>
>> Here is the code :
>>
>> $.ajax({
>> "dataType": 'json',
>> "type": "GET",
>> "url":
>> Routing.generate(myBundle_molstructure_ajax', {
>> "Id": id
>> }),
>> "success": function (dataStr) {
>> // get sdf and prepare
>> sdf="|"+String(dataStr['sdf']).replace(/\|/g,"");
>> sdf=sdf.replace(/\r\n/g,"|");
>> sdf=sdf.replace(/\n/g,"|");
>> sdf=sdf.replace(/\r/g,"|");
>> sdf=sdf.replace(/\|/g,"\n|");
>>
>> eval("document." + applet_name +
>> '.LoadInline(\"' + sdf + '\");');
>>
>> }
>> });
>>
>> The error i got is :
>>
>> SyntaxError: unterminated string literal at
>> document.jmol2.LoadInline("
>>
>> Is there something i can do ?
>> I don't think my inline file preparation is wrong but who knows...
>>
>> Thanks
>>
>> ------------------------------------------------------------------------------
>> Free Next-Gen Firewall Hardware Offer
>> Buy your Sophos next-gen firewall before the end March 2013
>> and get the hardware for free! Learn more.
>> http://p.sf.net/sfu/sophos-d2d-feb
>> _______________________________________________
>> Jmol-users mailing list
>> Jmol-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
> ------------------------------------------------------------------------------
> Free Next-Gen Firewall Hardware Offer
> Buy your Sophos next-gen firewall before the end March 2013
> and get the hardware for free! Learn more.
> http://p.sf.net/sfu/sophos-d2d-feb_______________________________________________
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users