gpt4 book ai didi

javascript - MVC Loop 内的表单在 Chrome 中自动提交

转载 作者:行者123 更新时间:2023-11-28 07:33:18 25 4
gpt4 key购买 nike

出于某种原因,表单会在 Chrome 中自动提交,但在 Firefox 中不会。谁能指出我做错了什么?

@foreach (var friend in Model.FacebookFriends2.Where(d => !Model.CaseContacts.Select(c => c.ImportedFrom.Replace("Facebook_", "")).Contains(d.ID) && d.FullName.StartsWith(heading.ToString())))
{
<li class="@string.Format("row{0}", friend.ID)">
@{
var fullName = friend.FullName;
if (fullName.Length > 30)
{
fullName = fullName.Substring(0, 30) + "...";
}
}
@using (Ajax.BeginForm("MyConnections", new {@caseid = Model.LayoutViewModel.CurrentCaseID,
@img = "http://graph.facebook.com/" + @friend.ID + "/picture?width=720&height=720",
@UNQID = friend.ID, @source = "Facebook"},
new AjaxOptions {HttpMethod = "Post", InsertionMode = InsertionMode.Replace, UpdateTargetId = "MyConnections"}))
{
<a class="fblinkadd" href="javascript:void" onclick="$('.@string.Format("row{0}", friend.ID)').hide();">
<span class="thumbnail">
<img src="http://graph.facebook.com/@friend.ID/picture?height=55&width=55">
</span> @fullName
</a>
}
</li>
}

然后在页面底部使用此脚本

$(document).ready(function () {
$('.fblinkadd').click(function() {
$(this).closest('form').submit();
});
});

最佳答案

看看这篇关于 Ajax.Beginform 的文章。我在您的示例中没有看到任何内容显示您想要将 HTML 替换为标记为“MyConnections”的内容

Ajax.beginform executing full postback instead of partial

@using (Ajax.BeginForm("ShowPartial", new AjaxOptions()
{
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "dane"
}))
{
<input type="submit" value="click"/>
}

<div id="dane">
@Html.Action("ShowPartial")
</div>

关于javascript - MVC Loop 内的表单在 Chrome 中自动提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28880427/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com