Ajax.ActionLink调用控制器两次

时间:2015-06-08 21:54:27

标签: jquery asp.net-mvc asp.net-ajax

我有一个问题,Ajax.ActionLink调用控制器两次。我读过类似的问题,但我无法解决。我不是多次包括jquery。我在源代码中检查了它:  http://i.stack.imgur.com/fJGJv.png

获取请求:

首先:

curl "http://localhost:64240/Group/SetPrice?groupId=10&X-Requested-   With=XMLHttpRequest&_=1433799153696" -H "Accept: */*" -H "Referer: http://localhost:64240/Group" -H "X-Requested-With: XMLHttpRequest" -H "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36" --compressed

第二

curl "http://localhost:64240/Group/SetPrice?groupId=10" -H "Accept:    text/html, */*; q=0.01" -H "Referer: http://localhost:64240/Group" -H "X-Requested-With: XMLHttpRequest" -H "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36" --compressed

Controller Method片段:

public ActionResult SetPrice(string name, int? page, int groupId)
{
        ViewData["name"] = name;
        int currentPageIndex = page.HasValue ? page.Value : 1;
        ...
}

ActionLink的:

 @Ajax.ActionLink(" ", "SetPrice", new { groupId = item.GroupId },
 null, new { @class = "modal-link btn btn-info ion-gear-b", style = "font-  size: 12px;margin-right:10px;", title = "Set Price" })

请求发起人

第一次请求:

send    @   jquery-2.1.4.js:8630 
jQuery.extend.ajax  @   jquery-2.1.4.js:8166
asyncRequest    @   jquery.unobtrusive-ajax.js:128
(anonymous function)    @   jquery.unobtrusive-ajax.js:138
jQuery.event.dispatch   @   jquery-2.1.4.js:4435
elemData.handle @   jquery-2.1.4.js:4121

第二

send    @   jquery-2.1.4.js:8630
jQuery.extend.ajax  @   jquery-2.1.4.js:8166
jQuery.fn.load  @   jquery-2.1.4.js:8861
Modal   @   bootstrap.js:804
(anonymous function)    @   bootstrap.js:982
jQuery.extend.each  @   jquery-2.1.4.js:374
jQuery.fn.jQuery.each   @   jquery-2.1.4.js:139
$.fn.modal  @   bootstrap.js:977
(anonymous function)    @   bootstrap.js:1012
jQuery.event.dispatch   @   jquery-2.1.4.js:4435
elemData.handle @   jquery-2.1.4.js:4121

0 个答案:

没有答案