Wednesday, May 23, 2012

Ajax request not working (asp.net-mvc)

View:



@{
AjaxOptions ajax = new AjaxOptions() { HttpMethod = "POST", UpdateTargetId = "sub_id" };
Layout = null;
}
<div id="sub_id">
</div>
@using (Ajax.BeginForm(ajax))
{
@Html.TextBox("email");
<input type="submit" value="???????????" />
}


controller:



[HttpPost]
public ContentResult LeftMenuSubscription(string email)
{
return new ContentResult(){Content = "<script>alert('Thanks')</script>"};
}


"Thanks" alert show.



but in div 'sub_id' set all page(...).



<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script> 


- connected.



html:



<html>
<head>
<title>??????? ????????</title>
<link href="/Content/Site.css" rel="stylesheet" type="text/css">
<script src="/Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery.unobtrusive-ajax.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery.validate.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
<script src="/Scripts/jQueryFixes.js" type="text/javascript"></script>
</head>
<body>
....
<form action="/" data-ajax="true" data-ajax-method="POST" data-ajax-mode="replace" data-ajax-update="#sub_id" id="form0" method="post">
<input id="email" name="email" type="text" value="">
<input type="submit" value="???????????">
</form>
...
</body>
</html>


what could be the problem?





No comments:

Post a Comment