我在asp.net mvc视图中有以下内容: -
<input type="submit" id="addswitch" data-targeturl="@Url.Action("showSwitches","Rack")" class="btn btn-small btn-primary" value="Add">
我的想法是,我需要将实际的URL insdie存储为一个任意值,我将其命名为data-targeturl。
然后在我的脚本中,当用户点击上面的输入字段时将触发,如下所示: -
$('body').on("click", "#addserver,#addsd,#addfirewall,#addrouter,#addswitch", function () {
$("#showAddDialog").dialog({
title: "Add Exsisting " + dialogtitle,
width: 'auto', // overcomes width:'auto' and maxWidth bug
maxWidth: 600,
height: 'auto',
modal: true,
fluid: true, //new option
resizable: false
});
var URL = this.data-targeturl;
但目前我收到以下错误: -
ReferenceError: targeturl is not defined
var URL = this.data-targeturl;