开发者

Ajax.BeginForm OnSuccess is opening a new window in IE and firefox

开发者 https://www.devze.com 2023-02-28 05:04 出处:网络
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

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" , OnS开发者_开发技巧uccess="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 ?


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:

window.clearText = function() {
    $('#SentMessage').val("");
}

Hope this helps

0

精彩评论

暂无评论...
验证码 换一张
取 消