Ajax.BeginForm OnSuccess 在 IE 和 Firefox 中打开一个新窗口
我的一个视图中有一个 ajax.begin 表单。当我在 chrome 和 firefix 中添加 OnSuccess = (javascript 函数) 时,它会打开一个新窗口。我在 JS 函数中所做的就是从字段中删除文本。在 IE 中它工作正常,它不会打开一个新窗口 -
代码 -
<% using (Ajax.BeginForm("SendMessages", "Chat", new RouteValueDictionary(new { controller = "Chat", action = "SendMessages", id = Model.MeetingID }), new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "Information" , OnSuccess="clearText"}))
{%>
$(function clearText() {
$('#SentMessage').val("");
return false;
});
有人能告诉我我做错了什么还是 chrome 和 firefox 有问题吗?
I have an ajax.begin form in one of my views. When I add OnSuccess = (javascript function), in chrome and firefix, it opens a new window. All I am doing in the JS function is to remove a text from the field. In IE it works fine, it doesnt open a new window -
CODE -
<% using (Ajax.BeginForm("SendMessages", "Chat", new RouteValueDictionary(new { controller = "Chat", action = "SendMessages", id = Model.MeetingID }), new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "Information" , OnSuccess="clearText"}))
{%>
$(function clearText() {
$('#SentMessage').val("");
return false;
});
Could some one tell me what I am doing wrong or is it a problem with chrome and firefox ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是无法找到
clearText
函数,因为它不是全局的。它不能在 $ 内。您可以将其移至 $ 之外或强制其为全局的,如下所示:希望这会有所帮助
The problem is that the
clearText
function can't be found cause it's not global. It must not be inside $. You can move it outside $ or force it to be global, as the following:Hope this helps