【发布时间】:2015-01-30 14:01:04
【问题描述】:
我有 api 控制器 public string GetCountries(int id){},我也有 ajax 脚本
<script>
$(document).ready(function () {
var id = $(this).attr('href');
$("#xid").click(function () {
$.ajax({
type: "GET",
dataType: "json",
url: "/api/Sports/GetCountries/" + id,
success: function (data) {
obj = JSON.parse(data);
alert(data);
for (var i = 0; i < data.length; i++) {
$("#getCountry").append("<a href=" + obj[i].Id + ">" + obj[i].Name + "</>" + "<br/>");
}
}
});
});
});
</script>
我的观点是这样的
<div style="float:left">
<div ng-app="" ng-controller="biloKojiKontroler">
<table class="tg">
<tr ng-repeat="x in biloKojeIme">
<th>
<a href="#" id="xid" value="{{x.id}}">{{x.name}}</a>
</th>
</tr>
</table>
</div>
</div>
我想单击锚标记以从我的 api 控制器获取数据,但是当我单击它时将我重定向到另一个页面。
【问题讨论】:
-
检查页面加载后是否有javascript错误,这是做什么的
$(this).attr('href')? -
你可以问你的朋友。,,, stackoverflow.com/questions/28235639/…的副本
-
没有错误...只是重定向到另一个页面
-
我试过了,但没有任何反应
-
同样...没有用
标签: jquery asp.net-mvc angularjs