Error:unterminated string literal in js

I spent lot of time to solve the issue.But i couldnt solve.I am new to javascript.I am using CHTML drpdown in my view.when i select one item from dropdown i want to call an action through ajax.from the action render a view by using renderPartial method.I am using chart js extensions in the view.But it shows error in firefox as given below.

[u][i][b][b]SyntaxError: unterminated string literal

var chart = new Chart($("[/b][/b][/i][/u]

Please reply as soon as possible…

the js code is given below

[b][i]$cs->registerScript(

        __CLASS__.'#'.$this->htmlId, 


        "var chart = new Chart($(\"#".$this->htmlId."\").get(0).getContext(\"2d\")).Bar(".$data.",".$options.");"


    );[/i][/b]

If i call chartjs widget in a view it works fine.But if i call widget through ajax dropdown it doesnot work.

I don’t know where specifically it’s gone wrong, but you could make the string much easier to read by using single quotes in the JavaScript and making use of variable interpolation in the PHP code:




"var chart = new Chart($('{$this->htmlId}').get(0).getContext('2d')).Bar($data, $options);"



thanks for the reply.it worked.the problem is that i split my js code by using "#".

Please make all of the changes that I suggested above. Eliminating the double quotes completely from the string will make it easier to read.