【发布时间】:2016-11-14 19:34:39
【问题描述】:
我有一些存储过程,其中放出一些 html 和 javascript,当我在浏览器中调用它们时(存储过程门户网站,Sas 9.3)它们可以工作:
工作示例:
put '<script type="text/javascript">';
if _n_ = 1 then do;
put 'function spSDesc(index){';
put 'document.getElementById("descText").value=spDescs[index];';
/*or put "document.getElementById(%str(%"descText%")).value=spDescs[index];";*/
put '};';
put '</script>';
这很好用。
但现在我想做一些 jquery 代码,但它不能那样工作:
put " <script src=%STR(%"https://code.jquery.com/jquery-1.12.4.js%")></script>";
put " <script src=%STR(%"https://code.jquery.com/ui/1.12.0/jquery-ui.js%")></script>";
put "<script>";
put " $( function() {";
put " $(%str(%"#datepicker%")).datepicker();";
/* or put ' $("#datepicker").datepicker();';*/
put " } );";
put "</script>";
在浏览器中给我一个错误:
Mozilla 火狐:
15:19:47.465 SyntaxError: 预期表达式,得到 '&'1 do:1400:3
IE
SCRIPT1002:Syntaxfehler Datei:do,Zeile:1400,Spalte:5
浏览器中的代码:
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
<script>
$( function() {
$("#datepicker").datepicker();
} );
</script>
所以" 处理不正确,如果我在一些依赖于 jquery 的代码中使用它(请参阅它对于脚本 src= 部分的工作正确)。
有人可以帮我解决这个问题吗?我需要以另一种方式转义",还是使用其他jquery代码?或者它根本不适用于 jquery?
编辑:
据我了解,问题是:
&quot; 不被解释为 ",所以我得到一个语法错误
所以我需要 stp 编写 "´ 而不是 &quot; 或让 jquery/javascript/browser 将 &quot; 解释为函数内部的 "。
EDIT2 + 解决方案: 在我的工作环境中,我只使用文件 _webout(我的工作示例来自那里),我认为在我的测试环境中我可以使用文件打印作为等效项,但我错了。我的示例中没有包含完整的输出代码,因此无法解决,对此我深表歉意。
data _null_;
*file print; /*does not work correct with "*/
file _webout;/*does work correct with "*/
put ...... /*example code comes here*/
run;
【问题讨论】: