Javascript 未定义jQuery打印局部视图
我想准备内容并在点击按钮时打印出来。但我有错误 index.cshtml:Javascript 未定义jQuery打印局部视图,javascript,jquery,asp.net-mvc,Javascript,Jquery,Asp.net Mvc,我想准备内容并在点击按钮时打印出来。但我有错误 index.cshtml: @{ ViewBag.Title = "Home Page"; } <button>Get External Content</button> <br /> <div id="printForm"> </div> <script> $(document).ready(function () { $('butt
@{
ViewBag.Title = "Home Page";
}
<button>Get External Content</button>
<br />
<div id="printForm">
</div>
<script>
$(document).ready(function () {
$('button').click(function (e) {
$.ajax({
type: "POST",
url: '@Url.Action("MyPartialView")',
data: {
'p': "xxx"
},
success: function (result) {
$('#printForm').empty();
$('#printForm').html(result);
$('#printForm').print();
},
error: function (xhr, ajaxOptions, thrownError) {
// bu kısımda eğer ajax işlemi başarısız ise
// hata mesajı verebiliriz.
alert(xhr.responseText);
}
});
});
});
</script>
MyPartialView.cshtml:
<span id="manchego"></span>
<script>
jQuery(document).ready(function () { //here is error: Uncaught ReferenceError: jQuery is not defined
$("#manchego").kendoBarcode({
value: "2346722",
type: "ean8",
width: 280,
height: 100
});
});
</script>
jQuery(document).ready(函数(){//这里是错误:未捕获引用错误:未定义jQuery
$(“#manchego”)。kendoBarcode({
值:“2346722”,
输入:“ean8”,
宽度:280,
身高:100
});
});
如果我评论打印方法,它可以正常工作。但是$('#printForm')。print()代码>不工作。
错误:未捕获引用错误:未定义jQuery
我不必使用jquery.print.js。我应该如何打印局部视图?我怀疑jquery被定义了不止一次。您确定它们是一致的吗?如果我在partila视图中的jquery.ready中打印方法,它会工作@sepehr div id=“ppp”>jQuery(document).ready(函数(){$(“#manchego”).kendoBarcode({值:“2346722”,类型:“ean8”,宽度:280,高度:100});$(“#ppp”).print()});我曾经在使用ajax添加网格时遇到kendo grid excel导出问题,解决方案是删除冗余的jquery,无论如何,我在等待您的问题的解决方案。我怀疑,jquery被定义了不止一次。您确定它们是一致的吗?如果我在partila视图中的jquery.ready中打印方法,它会工作@sepehr div id=“ppp”>jQuery(document).ready(函数(){$(“#manchego”).kendoBarcode({值:“2346722”,类型:“ean8”,宽度:280,高度:100});$(“#ppp”).print()});有一次我在使用ajax添加网格时遇到了kendo grid excel导出的问题,解决方案是删除冗余的jquery,不管怎样,我也在等待您的问题的解决方案
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult MyPartialView(string p=null)
{
return PartialView();
}
<span id="manchego"></span>
<script>
jQuery(document).ready(function () { //here is error: Uncaught ReferenceError: jQuery is not defined
$("#manchego").kendoBarcode({
value: "2346722",
type: "ean8",
width: 280,
height: 100
});
});
</script>