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
精彩评论