Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 是否使用Jquery获取Mvc3 Ajax.ActionLink替换的数据?_C#_Jquery_.net_Ajax_Asp.net Mvc 3 - Fatal编程技术网

C# 是否使用Jquery获取Mvc3 Ajax.ActionLink替换的数据?

C# 是否使用Jquery获取Mvc3 Ajax.ActionLink替换的数据?,c#,jquery,.net,ajax,asp.net-mvc-3,C#,Jquery,.net,Ajax,Asp.net Mvc 3,我有一个@Ajax.ActionLink,它用另一个同样有@Ajax.ActionLink的内容替换了自己的包装器,该内容将第一个html内容返回给包装器。它的链接部分,取代了它的自我和反之亦然。我的问题是,当我想在click to ActionLink上使用一些传统功能时,我的Jquery会返回旧的部分功能,即已单击的部分功能,而不是新功能,在firebug中,我清楚地看到了我的新元素,但无法访问它们,我尝试了,成功了,完成了,但没有成功!有什么想法吗 下面是一个例子: 查看 @Ajax.Ac

我有一个
@Ajax.ActionLink
,它用另一个同样有
@Ajax.ActionLink
的内容替换了自己的包装器,该内容将第一个html内容返回给包装器。它的链接部分,取代了它的自我和反之亦然。我的问题是,当我想在click to ActionLink上使用一些传统功能时,我的Jquery会返回旧的部分功能,即已单击的部分功能,而不是新功能,在firebug中,我清楚地看到了我的新元素,但无法访问它们,我尝试了,成功了,完成了,但没有成功!有什么想法吗

下面是一个例子:

查看

@Ajax.ActionLink("Get partial two", "getPartial2", "Home",
                new AjaxOptions
                    {
                        UpdateTargetId = "box",
                        InsertionMode = InsertionMode.Replace,
                        HttpMethod = "GET",
                        OnComplete = "getNewData"       
                    },
                    new { @class="first"}
                )
<div id="testBox1">Hello, I am partial 1</div>
index.cshtml

JS

$("#box a.first").live('click', function () {

    //how to fetch new data, that was filled with getPartial2()

    console.log($(this).parent().children());

    //this returns [a.first, div#testBox1] 
   // and I need [a.second, div#testBox2] 
});
function getNewData()
{
    console.log($(this));

    //this returns [Object] of ajax call, niether
   // $(this).parent/s(), or $(this).children() is posible

}
如果需要,如何选择返回的数据,比如子字符串

编辑

使用OnComplete=“函数”

查看

@Ajax.ActionLink("Get partial two", "getPartial2", "Home",
                new AjaxOptions
                    {
                        UpdateTargetId = "box",
                        InsertionMode = InsertionMode.Replace,
                        HttpMethod = "GET",
                        OnComplete = "getNewData"       
                    },
                    new { @class="first"}
                )
<div id="testBox1">Hello, I am partial 1</div>

如何选择称之为ajax的元素的子元素?

我想我并不是您想要的100%,但我认为您的问题可能是缓存。如果您在GET请求上添加了一个唯一的参数,那么您是否得到了所需的结果

@Ajax.ActionLink("Get partial two", "getPartial2", "Home", new { aparam = DateTime.Now.Ticks },
                new AjaxOptions
                    {
                        UpdateTargetId = "box",
                        InsertionMode = InsertionMode.Replace,
                        HttpMethod = "GET",
                        OnComplete = "completeGetThing"       
                    },
                    new { @class="first"}
                )
<div id="testBox1">Hello, I am partial 1</div>
@Ajax.ActionLink(“getpartialtwo”,“getPartial2”,“Home”,new{aparam=DateTime.Now.Ticks},
新选择
{
UpdateTargetId=“box”,
InsertionMode=InsertionMode.Replace,
HttpMethod=“GET”,
OnComplete=“completeGetThing”
},
新建{@class=“first”}
)
你好,我是第1部分

@Darin Dimitrov,你能看看这个吗……从jQuery 1.7开始,.live()就不推荐使用了。您应该使用.on()@扎克格林,谢谢,但这并不能解决这个问题?这就是我为什么要发表评论而不是评论的原因answer@ZachGreen,有什么想法吗?我的目标是让控制器返回新元素,点击触发ActionLink的相同按钮,这样我就可以操纵它们了。。。在显示之前。为OnComplete参数提供javascript函数将设置该函数在操作完成时执行,然后您可以根据需要操纵页面。
@Ajax.ActionLink("Get partial two", "getPartial2", "Home",
                new AjaxOptions
                    {
                        UpdateTargetId = "box",
                        InsertionMode = InsertionMode.Replace,
                        HttpMethod = "GET",
                        OnComplete = "getNewData"       
                    },
                    new { @class="first"}
                )
<div id="testBox1">Hello, I am partial 1</div>
function getNewData()
{
    console.log($(this));

    //this returns [Object] of ajax call, niether
   // $(this).parent/s(), or $(this).children() is posible

}
@Ajax.ActionLink("Get partial two", "getPartial2", "Home", new { aparam = DateTime.Now.Ticks },
                new AjaxOptions
                    {
                        UpdateTargetId = "box",
                        InsertionMode = InsertionMode.Replace,
                        HttpMethod = "GET",
                        OnComplete = "completeGetThing"       
                    },
                    new { @class="first"}
                )
<div id="testBox1">Hello, I am partial 1</div>