0

I am using $.post() to call an ASP script, which among other things has the following code:

%>
    <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:

var strTributeID = $('body').data(tributeID);

However, the value does not appear to be retained, or perhaps not set correctly. What might be wrong?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Michael
  • 774
  • 7
  • 26

1 Answers1

0

You are not writing the NTC value to the page, only evaluating it and throwing it away. Use the <%= tag:

strTributeID = <%= NTC %>;
Guffa
  • 687,336
  • 108
  • 737
  • 1,005
  • This is classic ASP, so I don't believe that will work for me. – Michael Aug 31 '11 at 08:01
  • 1
    @Michael Hopkins: It's the same for classic ASP. `<% %>` is a code tag, and `<%= %>` is a display tag. `<%= %>` is short for `<%response.write( )%>`. – Guffa Aug 31 '11 at 08:24