[英]How to set .data() variable inside an ASP script so it can be accessed later?
I am using $.post()
to call an ASP script, which among other things has the following code: 我正在使用
$.post()
来调用ASP脚本,其中包括以下代码:
%>
<script type="text/javascript">
strTributeID = <% NTC %>
$('body').data(tributeID, strTributeID);
alert ($('body').data(tributeID));
</script>
<%
Before the page is refreshed (so DOM data should not have been wiped out), I call another $.post() which does this upon success: 在刷新页面之前(因此不应该删除DOM数据),我调用了另一个$ .post(),它在成功时执行此操作:
var strTributeID = $('body').data(tributeID);
However, the value does not appear to be retained, or perhaps not set correctly. 但是,该值似乎没有保留,或者可能设置不正确。 What might be wrong?
可能是什么问题?
You are not writing the NTC
value to the page, only evaluating it and throwing it away. 您不是将
NTC
值写入页面,而只是对其进行评估并将其丢弃。 Use the <%=
tag: 使用
<%=
标记:
strTributeID = <%= NTC %>;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.