[英]Open Javascript Id on a new window
Am trying to open an id on a new window, this is my code: 我正在尝试在新窗口中打开一个ID,这是我的代码:
<script type="text/javascript">
$(document).ready(function () {
$('.myButton').click(function () {
$.ajax({
type: "GET",
url: $(this).parent().data("url"),
data: { callNumber: $(this).parent().data("callno") },
success: function (data) {
$("#CallDetail").html(data);
},
});
});
});
</script>
When i click .myButton class it opens the id: 当我单击.myButton类时,它将打开ID:
<div id="CallDetail"></div>
thats located on the home page. 多数民众赞成在位于首页上。
What i need is to open on a new window, i have tried doing this via the link : 我需要在一个新窗口中打开,我尝试通过链接进行此操作:
<div data-callno='@parts.Call_Num' data-url="@Url.Action("GetCallInfo", "CallHandling" , new {target = "_blank"})">
<div class="myButton toolbarIcon">
<div class="toolbarIconText">View</div>
</div>
But no luck, at the moment it just opens in the same page i am doing this, the problem is am getting data called in the JavaScript so its trickier then i imagined. 但是没有运气,目前我只是在同一页面中打开它,问题是要在JavaScript中调用数据,所以它比我想象的要难。 any ideas?
有任何想法吗?
You can use jQuery's .find
to search the returned HTML for a selector: 您可以使用jQuery的
.find
在返回的HTML中搜索选择器:
$(document).ready(function () {
$('.myButton').click(function () {
$.ajax({
type: "GET",
url: $(this).parent().data("url"),
data: { callNumber: $(this).parent().data("callno") },
success: function (data) {
$(data).find('#CallDetail');
},
});
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.