为什么ajax.actionlink结果会转到新的网页而不是指定的DIV元素? [英] Why are the ajax.actionlink results going to a new webpage instead of to a specified DIV element?

查看:94
本文介绍了为什么ajax.actionlink结果会转到新的网页而不是指定的DIV元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ASP.NET MVC中遇到另一个Ajax问题我有以下Ajax.ActionLink成功检索到所需的数据。问题是,不是将结果放入像Ajax那样的

I've run into another Ajax problem in ASP.NET MVC I have the following Ajax.ActionLink that successfully retrieves the desired data. The problem is, instead of placing the results into the

元素,而是重新加载网页,并将数据结果提供给其他空白网页的顶部。



我试图找出为什么它没有将结果放在div标签中。我目前没有使用局部视图,但我之前已经看到它完成了部分视图。



我尝试了什么:













@ Ajax.ActionLink(LOCUS,获取,api / CompRounds,

新{Param1 = 1,Param1 =dat1},

新的AjaxOptions

{

HttpMethod =GET,

UpdateTargetId =divCompRounds,

InsertionMode = InsertionMode.Replace

},new {style =margin-right:10px,@ class =btn btn-success})



element like Ajax is intended for, it instead reloads the web page and gives the data result at the top of an otherwise blank web page.

I'm trying to figure out why it's not placing the results in the div tag. I'm not currently using a partial view, but I've seen it done with and without a partial view before.

What I have tried:






@Ajax.ActionLink("LOCUS", "Get", "api/CompRounds",
new { Param1 = 1, Param1 = "dat1" },
new AjaxOptions
{
HttpMethod = "GET",
UpdateTargetId = "divCompRounds",
InsertionMode = InsertionMode.Replace
}, new { style = "margin-right:10px", @class = "btn btn-success" })







推荐答案

你可能不包括不引人注目的ajax js文件



MVC中的Ajax.ActionLink和Html.ActionLink

[ ^ ]



如果你包括它们确保它们正在加载(检查浏览器工具的网络选项卡)并检查错误控制台中是否存在其他js错误。你很可能不会包含不显眼的js文件。
You probably aren't including the unobtrusive ajax js files

Ajax.ActionLink and Html.ActionLink in MVC
[^]

If you are including them make sure they're loading ok (check the network tab of the browser tools) and also check there aren't other js errors in the error console. It's most likely that you're just not including the unobtrusive js files though.


这篇关于为什么ajax.actionlink结果会转到新的网页而不是指定的DIV元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆