请看下面的代码
function loadAds(zone, positionId) {
try {
var url = '/GetAds/?positionId=' + positionId + "&zone=" + zone;
$.ajax({
type: "POST",
contentType: 'application/json; charset=utf-8',
dataType: "json",
url: url,
success: function (response) {
var htmlcontent = "";
switch (zone) {
case '@zoneEnum.SideBar.ToString()':
$.each(response, function (index, item) {
var style = index !== 0 ? 'padding-top: 5px;' : '';
htmlcontent += "<div>" +
"<a href='/Adv/" + item.adLink + "'>" +
"<img src='/images/" + item.img + "'/>" +
"</a>" +
"</div>";
});
$("#div_@zoneEnum.SideBar.ToString()").html(htmlcontent);
break;
case '@zoneEnum.RightCol.ToString()':
$.each(response, function (index, item) {
htmlcontent += "";
});
break;
}
},
failure: function (msg) {
});
} catch (e) {
}
}
如何将loadAds函数放入外部js文件中 例如loadAds.js
,然后在html中仅将其命名为:
script type="text/javascript">
$(document).ready(function () {
loadAds('@zone','@positionId');
});
请查看案例语句,我需要在外部jquery中访问zoneEnum类,但不知道如何 可能吗? 非常感谢