but try it the way you were doing it:
var str= "string 'No.1' works";
var str= 'string "No.2" works';
//if you really want to use doubles inside of doubles, you need to escape them...
var str= "string \"No.3\" works";
//same with singles inside of singles...
var str= 'string \'No.4\' works';
and of course the quotes that you are introducing with php will affect all of that, too...
var str= "string "No.5" doesn't work";