{"id":180011,"date":"2013-05-17T12:03:02","date_gmt":"2013-05-17T08:03:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=180011"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=180011","title":{"rendered":"<span class=\"post_title\">\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f AJAX \u0432 ASP.NET MVC 4<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041d\u0430\u0432\u0435\u0440\u043d\u043e \u0443\u0436\u0435 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u0435\u0431 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0441\u043b\u044b\u0448\u0430\u043b \u043e Ajax. Microsoft \u0432 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0435, \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u0440\u0435\u043b\u0438\u0437\u043e\u043c \u0441\u0442\u0430\u0440\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0436\u0438\u0437\u043d\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u043c, ASP.NET MVC \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c. \u041d\u043e \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0443 \u0441\u0442\u0430\u0442\u044c\u044e, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u044e\u0441\u044c \u043e\u0442 \u0442\u0435\u043c\u044b.<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u044f \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0441\u044f \u0441 MVC \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c, \u043e\u043d \u0431\u044b\u043b \u0442\u043e\u0433\u0434\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0438, \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0432\u0448\u0438\u0441\u044c \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0445\u0435\u043b\u043f\u0435\u0440\u0430\u043c\u0438 \u043a\u0430\u043a <code>@Ajax....<\/code>, \u0447\u0435\u0441\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043c\u0435\u043d\u044f \u043d\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0438\u043b\u0430. \u041d\u0435\u0442, \u0442\u0430\u043a \u043d\u0435\u0442, \u043f\u043e\u0434\u0443\u043c\u0430\u043b \u044f \u043f\u0440\u043e \u0441\u0435\u0431\u044f, \u0443 \u043c\u0435\u043d\u044f \u0435\u0441\u0442\u044c jQuery \u0441\u043e \u0441\u0432\u043e\u0438\u043c <code>$.ajax<\/code>, \u043c\u043d\u0435 \u0435\u0433\u043e \u0437\u0430 \u0433\u043b\u0430\u0437\u0430. \u0412\u043e\u0442 \u0438 \u0437\u0430\u0431\u044b\u043b \u044f \u043f\u0440\u043e \u043d\u0438\u0445 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442, \u043a \u0441\u0432\u043e\u0435\u043c\u0443 \u0432\u0435\u043b\u0438\u043a\u043e\u043c\u0443 \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u043f\u0440\u043e\u043c\u043e\u0440\u0433\u0430\u0432 \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441 \u0442\u0440\u0435\u0442\u044c\u0438\u043c \u0440\u0435\u043b\u0438\u0437\u043e\u043c. \u0427\u0442\u043e \u0431\u044b\u043b\u043e, \u0442\u043e \u0431\u044b\u043b\u043e. \u0411\u043b\u0430\u0433\u043e \u0447\u0442\u043e \u0432\u0437\u044f\u043b\u0441\u044f \u0437\u0430 \u0443\u043c \u0438 \u043f\u043e\u0447\u0438\u0442\u0430\u043b \u0434\u0432\u0435 \u043a\u043d\u0438\u0433\u0438 \u043f\u043e MVC 4. \u0414\u0430\u043b\u0435\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0445\u0435\u043b\u043f\u0435\u0440\u043e\u043c \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0445 \u043c\u043d\u043e\u044e \u0432\u044b\u0448\u0435.<\/p>\n<p>  \u041d\u0430\u0447\u043d\u0443 \u0441 \u0442\u043e\u0433\u043e \u0447\u0442\u043e MVC \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0434\u0432\u0443\u043c\u044f \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u043c\u0438 Ajax \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a (\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u044f \u0436\u0435 \u0438\u043c\u0435\u044e \u0432\u0432\u0438\u0434\u0443 \u0441 \u043a\u043e\u0440\u043e\u0431\u043a\u0438, \u043d\u0438 \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e) \u2014 jQuery \u0438 Microsoft Ajax. \u0427\u0442\u043e\u0431\u044b \u0437\u043d\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0443 \u0434\u043b\u044f \u043a\u0430\u043a\u043e\u0433\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0432 <code>web.config<\/code> <code>UnobtrusiveJavaScriptEnabled<\/code> \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>true<\/code> (\u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 jQuery) \u0438 f<code>alse<\/code> (\u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Microsoft Ajax). \u0415\u0441\u043b\u0438 \u0436\u0435 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u2014 <code>@{Html.EnableUnobtrusiveJavaScript(bool);}<\/code>. \u0425\u043e\u0447\u0443 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0432\u043b\u0438\u044f\u0435\u0442 \u0438 \u043d\u0430 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430.<\/p>\n<p>  <a name=\"habracut\"><\/a><br \/>  \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043a\u0430\u043a\u043e\u0432 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0432\u0430\u043c \u0431\u043e\u043b\u0435\u0435 \u043f\u043e \u0434\u0443\u0448\u0435, \u0432\u0430\u043c \u043d\u0435 \u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0430\u0434\u0430\u043f\u0442\u0435\u0440. \u0414\u043b\u044f Microsoft Ajax<\/p>\n<pre><code class=\"html\">&lt;script src=&quot;~\/Scripts\/MicrosoftAjax.js&quot; type=&quot;text\/javascript&quot;&gt;&lt;\/script&gt; &lt;script src=&quot;~\/Scripts\/MicrosoftMvcAjax.js&quot; type=&quot;text\/javascript&quot;&gt;&lt;\/script&gt; <\/code><\/pre>\n<p>  , a \u0434\u043b\u044f jQuery<\/p>\n<pre><code class=\"html\">&lt;script src=&quot;~\/Scripts\/jquery.unobtrusive-ajax.min.js&quot; type=&quot;text\/javascript&quot;&gt;&lt;\/script&gt;<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u044f \u043f\u0438\u0441\u0430\u043b \u0432\u044b\u0448\u0435, \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 jQuery \u043c\u0435\u043d\u044f \u0432\u043f\u043e\u043b\u043d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0439\u0434\u0443 \u043f\u043e \u043f\u0443\u0442\u0438 \u043d\u0435\u043d\u0430\u0432\u044f\u0437\u0447\u0438\u0432\u043e\u0433\u043e JavaScript (\u0442.\u0435. <code>web.config<\/code> \u0441 <code>&lt;add key=&quot;UnobtrusiveJavaScriptEnabled&quot; value=&quot;true&quot; \/&gt;<\/code>), \u0438 \u043d\u0430\u0447\u043d\u0443 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e.<\/p>\n<h4>ActionLink<\/h4>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0430\u043a\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443. \u0415\u0441\u0442\u044c \u0441\u0441\u044b\u043b\u043e\u0447\u043a\u0430, \u043a\u043b\u0438\u043a\u043d\u0443\u0432 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u043b \u044f \u0440\u0430\u043d\u0435\u0435.<\/p>\n<p>  \u041a\u0443\u0441\u043e\u0447\u0435\u043a \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f<\/p>\n<pre><code class=\"cs\">public ActionResult Index() { \tif (Request.IsAjaxRequest()) \t\treturn PartialView(&quot;_IndexPartial&quot;);  \treturn View(); } <\/code><\/pre>\n<p>  <code>Index<\/code> \u043f\u0440\u0435\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/p>\n<pre><code class=\"html\">&lt;script type=&quot;text\/javascript&quot;&gt; \t jQuery(function($) { \t \t$('#update-container').click(function(e) { \t \t\te.preventDefault();  \t \t\t$.ajax({ \t \t\t\turl: '@Url.Action(&quot;Index&quot;, &quot;Home&quot;)', \t \t\t\tsuccess: function(data) { \t \t\t\t\t$('#container').html(data); \t \t\t\t} \t \t\t}); \t \t}) \t })  &lt;\/script&gt;  &lt;div id=&quot;container&quot;&gt; \t@Html.Partial(&quot;_IndexPartial&quot;) &lt;\/div&gt;  @Html.ActionLink(&quot;\u041f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435&quot;, &quot;Index&quot;, &quot;Home&quot;, new {}, new {id = &quot;update-container&quot;}) <\/code><\/pre>\n<p>  <code>_IndexPartial<\/code> \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/p>\n<pre><code class=\"html\">&lt;div&gt;\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430&lt;\/div&gt; <\/code><\/pre>\n<p>  \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0443 \u0437\u043d\u0430\u043a\u043e\u043c \u0442\u0430\u043a\u043e\u0439 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043a\u0430\u043a <code>Html. ActionLink(...)<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435. \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043d\u0435 \u043c\u043d\u043e\u0433\u043e, \u0434\u0430 \u0438 \u043f\u0440\u0438\u0432\u044b\u043a \u0442\u0430\u043a \u0443\u0436\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0442\u0430\u043a \u0447\u0442\u043e \u0432\u0441\u0435 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u043d\u043e \u0432\u0435\u0434\u044c \u044f \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u043d\u0438\u0432\u044b\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0438 \u0432 \u043c\u0435\u0440\u0443 \u0441\u0432\u043e\u0438\u0445 \u0441\u0438\u043b \u0431\u043e\u0440\u044e\u0441\u044c \u0437\u0430 \u0447\u0438\u0441\u0442\u043e\u0442\u0443 \u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441 22 \u0441\u0442\u0440\u043e\u043a \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043e 5. \u0418 \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043a\u043e \u043c\u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 <code>Ajax.ActionLink(...)<\/code> (\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0441\u043a\u0435\u043f\u0442\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0447\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e <code>$.ajax<\/code> \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>.load<\/code> \u0438\u043b\u0438 <code>$.get<\/code>, \u043d\u043e \u0441\u0443\u0442\u0438 \u044d\u0442\u043e \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442, \u043c\u044b \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438 \u0442\u0430\u043a \u043f\u043e\u0440\u043e\u0439 \u0443 \u043d\u0430\u0441 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043f\u0443\u0445\u043d\u0443\u0442\u044c)<\/p>\n<p>  \u0412\u0443\u0430\u043b\u044f, <code>Index<\/code> \u043f\u0440\u0435\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/p>\n<pre><code class=\"html\">&lt;div id=&quot;container&quot;&gt; \t@Html.Partial(&quot;_IndexPartial&quot;) &lt;\/div&gt;  @Ajax.ActionLink(&quot;\u041f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435&quot;, &quot;Index&quot;, &quot;Home&quot;, new {}, new AjaxOptions{UpdateTargetId = &quot;container&quot;}, new {id = &quot;update-container&quot;}) \/\/id \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u0430\u043c \u0443\u0436\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u044e <\/code><\/pre>\n<p>  \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 <code>Html.ActionLink<\/code> \u0438 <code>Ajax.ActionLink<\/code> \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435, \u043e\u0431\u044a\u0435\u043a\u0442\u0435 <code>AjaxOptions<\/code>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e \u043d\u0435\u043c \u0438 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c.<\/p>\n<h4>AjaxOptions<\/h4>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/028\/668\/d4a\/028668d4a01b0ae9d35ce87511adf676.png\"\/><\/p>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u0443 \u043d\u0435\u0433\u043e \u043d\u0435 \u043c\u043d\u043e\u0433\u043e, \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u044d\u0442\u043e \u0438 \u0445\u043e\u0440\u043e\u0448\u043e, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0435\u0431\u0440\u044f\u043d\u0443\u044e \u043f\u0443\u043b\u044e, \u0431\u0443\u0434\u044c \u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u043b\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u043e\u0439 \u0438 \u043d\u0435\u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0439.<\/p>\n<p>  \u0427\u0442\u043e \u0438\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0437\u0430 \u0447\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442, \u043b\u0443\u0447\u0448\u0435 MSDN \u044f \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435 \u0441\u043c\u043e\u0433\u0443.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/8b1\/39d\/797\/8b139d7974a316a5510ee1175368dfa2.png\"\/><\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0431\u0435\u0436\u0438\u043c\u0441\u044f \u043f\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c:<\/p>\n<p>  <code>Confirm<\/code> \u2014 \u0430\u043d\u0430\u043b\u043e\u0433 javascript <code>confirm(...)<\/code><\/p>\n<p>  <code>HttpMethod<\/code> \u2014 \u0442\u0438\u043f\u0430 <code>string<\/code>, \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0447\u0442\u043e \u0436\u0435 MS \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e 2 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u0443\u043c\u0430 \u043d\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0443 \u043f\u043e\u0447\u0435\u043c\u0443, \u0438 \u0432\u0438\u0434\u0438\u043c\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0442\u0430\u043a\u043e\u0432, \u0432\u0441\u0435 \u0447\u0442\u043e \u043d\u0435 <code>GET<\/code>, <code>null<\/code> \u0438\u043b\u0438 \u043f\u0443\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u043e\u0441\u043b\u0435 <code>.Trim()<\/code> \u2014 \u0432\u0441\u0435 <code>POST<\/code><\/p>\n<p>  <code>InsertionMode<\/code> \u2014 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 &quot;<code>InsertAfter<\/code>&quot; (\u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u043a\u043e\u043d\u0435\u0446 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430), &quot;<code>InsertBefore<\/code>&quot; (\u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430) \u0438\u043b\u0438 &quot;<code>Replace<\/code>&quot; (\u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430)<\/p>\n<p>  <code>Loading...<\/code> \u2014 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u0440\u044b\u0442\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442<\/p>\n<p>  <code>On.....<\/code> \u2014 javascript \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0441 <code>$.ajax<\/code>  <\/p>\n<ul>\n<li><code>OnBegin<\/code> \u2014 <code>beforeSend<\/code><\/li>\n<li><code>OnComplete<\/code> \u2014 <code>complete<\/code><\/li>\n<li><code>OnFailure<\/code> \u2014 <code>error<\/code><\/li>\n<li><code>OnSuccess<\/code> \u2014 <code>success<\/code><\/li>\n<\/ul>\n<p>  <code>Url<\/code> \u2014 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 ajax \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0437\u0432\u0435\u0441\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0442 ajax \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u043e \u0440\u0430\u0437\u043d\u044b\u043c \u0440\u043e\u0443\u0442\u0430\u043c\/\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c\/\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u043c\/\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c (\u043d\u0443\u0436\u043d\u043e\u0435 \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u043d\u0443\u0442\u044c)<\/p>\n<h4>Ajax \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b<\/h4>\n<p>  \u041f\u043e\u0434 \u043a\u043e\u043d\u0435\u0446 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u0432\u0440\u0435\u043c\u044f \u043e\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0442 \u043d\u0430\u0448\u0443 \u0436\u0438\u0437\u043d\u044c<\/p>\n<h4>\u0420\u0435\u0437\u044e\u043c\u0435<\/h4>\n<p>  \u0426\u0435\u043b\u044c\u044e \u043c\u043e\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0431\u044b\u043b\u043e \u043b\u0438\u0448\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0435\u0449\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0438 \u043d\u0435 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u0442\u044c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 (\u0441\u0443\u0436\u0443 \u043b\u0438\u0448\u044c \u043f\u043e \u0441\u0435\u0431\u0435).<\/p>\n<hr\/>\n<p>  \u041d\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u0435\u043d\u044f \u0441\u043f\u043e\u0434\u0432\u0438\u0433\u043b\u0438 \u0433\u043b\u0430\u0432\u044b \u043a\u043d\u0438\u0433:<br \/>  <a href=\"http:\/\/www.smarly.net\/asp-net-mvc-4-in-action\/working-with-asp-net-mvc\/ajax-in-asp-net-mvc\">Ajax \u0432 ASP.NET MVC (ASP.NET MVC 4 \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438)<\/a><br \/>  \u0438 <br \/>  <a href=\"http:\/\/www.smarly.net\/pro-asp-net-mvc-4\/asp-net-mvc-4-in-detail\/url-and-ajax-helper-methods\">\u0412\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f URL \u0438 Ajax (pro ASP.NET MVC 4)<\/a><\/p>\n<hr\/>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/180011\/\"> http:\/\/habrahabr.ru\/post\/180011\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041d\u0430\u0432\u0435\u0440\u043d\u043e \u0443\u0436\u0435 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u0435\u0431 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0441\u043b\u044b\u0448\u0430\u043b \u043e Ajax. Microsoft \u0432 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0435, \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u0440\u0435\u043b\u0438\u0437\u043e\u043c \u0441\u0442\u0430\u0440\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0436\u0438\u0437\u043d\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u043c, ASP.NET MVC \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c. \u041d\u043e \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0443 \u0441\u0442\u0430\u0442\u044c\u044e, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u044e\u0441\u044c \u043e\u0442 \u0442\u0435\u043c\u044b.<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u044f \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0441\u044f \u0441 MVC \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c, \u043e\u043d \u0431\u044b\u043b \u0442\u043e\u0433\u0434\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0438, \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0432\u0448\u0438\u0441\u044c \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0445\u0435\u043b\u043f\u0435\u0440\u0430\u043c\u0438 \u043a\u0430\u043a <code>@Ajax....<\/code>, \u0447\u0435\u0441\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043c\u0435\u043d\u044f \u043d\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0438\u043b\u0430. \u041d\u0435\u0442, \u0442\u0430\u043a \u043d\u0435\u0442, \u043f\u043e\u0434\u0443\u043c\u0430\u043b \u044f \u043f\u0440\u043e \u0441\u0435\u0431\u044f, \u0443 \u043c\u0435\u043d\u044f \u0435\u0441\u0442\u044c jQuery \u0441\u043e \u0441\u0432\u043e\u0438\u043c <code>$.ajax<\/code>, \u043c\u043d\u0435 \u0435\u0433\u043e \u0437\u0430 \u0433\u043b\u0430\u0437\u0430. \u0412\u043e\u0442 \u0438 \u0437\u0430\u0431\u044b\u043b \u044f \u043f\u0440\u043e \u043d\u0438\u0445 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442, \u043a \u0441\u0432\u043e\u0435\u043c\u0443 \u0432\u0435\u043b\u0438\u043a\u043e\u043c\u0443 \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u043f\u0440\u043e\u043c\u043e\u0440\u0433\u0430\u0432 \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441 \u0442\u0440\u0435\u0442\u044c\u0438\u043c \u0440\u0435\u043b\u0438\u0437\u043e\u043c. \u0427\u0442\u043e \u0431\u044b\u043b\u043e, \u0442\u043e \u0431\u044b\u043b\u043e. \u0411\u043b\u0430\u0433\u043e \u0447\u0442\u043e \u0432\u0437\u044f\u043b\u0441\u044f \u0437\u0430 \u0443\u043c \u0438 \u043f\u043e\u0447\u0438\u0442\u0430\u043b \u0434\u0432\u0435 \u043a\u043d\u0438\u0433\u0438 \u043f\u043e MVC 4. \u0414\u0430\u043b\u0435\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0445\u0435\u043b\u043f\u0435\u0440\u043e\u043c \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0445 \u043c\u043d\u043e\u044e \u0432\u044b\u0448\u0435.<\/p>\n<p>  \u041d\u0430\u0447\u043d\u0443 \u0441 \u0442\u043e\u0433\u043e \u0447\u0442\u043e MVC \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0434\u0432\u0443\u043c\u044f \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u043c\u0438 Ajax \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a (\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u044f \u0436\u0435 \u0438\u043c\u0435\u044e \u0432\u0432\u0438\u0434\u0443 \u0441 \u043a\u043e\u0440\u043e\u0431\u043a\u0438, \u043d\u0438 \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e) \u2014 jQuery \u0438 Microsoft Ajax. \u0427\u0442\u043e\u0431\u044b \u0437\u043d\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0443 \u0434\u043b\u044f \u043a\u0430\u043a\u043e\u0433\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0432 <code>web.config<\/code> <code>UnobtrusiveJavaScriptEnabled<\/code> \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>true<\/code> (\u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 jQuery) \u0438 f<code>alse<\/code> (\u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Microsoft Ajax). \u0415\u0441\u043b\u0438 \u0436\u0435 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u2014 <code>@{Html.EnableUnobtrusiveJavaScript(bool);}<\/code>. \u0425\u043e\u0447\u0443 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0432\u043b\u0438\u044f\u0435\u0442 \u0438 \u043d\u0430 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-180011","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/180011","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=180011"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/180011\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=180011"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=180011"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=180011"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}