0
我在jquery中聲明瞭一個變量。該值是來自數據倉庫的部件號。即使大部分時間是一串數字,它總是一個字符串。當部件id是'4125052'的所有數字時,沒有錯誤,但如果第一個數字是像'B4125052'這樣的字符串,那麼我得到錯誤 - '錯誤:'B4125052'未定義。當我在輸出的頁面上查看/源時,我將該值看作$ itemid = B4125052; (不含引號)。jquery,當值爲字符串字符時,變量是undefined
<%string id = Model.Part.Select(x => x.Id).FirstOrDefault().Trim(); %>
<%int partsetupid = Model.PartSetUp.PartSetUpID; %>
<%int numtoprint = Model.NumContinuationTCs; %>
<script language="javascript" type="text/javascript">
$(this).ready(function() {
var $theHtml = null;
var $itemid=null;
var $partsetupid=null;
$itemid=<%=id%>;
setupid=<%=partsetupid%>;
theHtml = $("html").html()
$.download('<%= Url.Action("TravelCardReport","Reports") %>', { filename_: $itemid, format: "pdf", numtoprint_:<%=numtoprint%>, html_: theHtml,partsetupid_:setupid }, "post");
$('#Wrapper').hide();
});
</script>
你幾乎回答了你自己的問題 「[..]我看到了價值$的itemid = B4125052;(不包括引號)」 – Znarkus