Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Ajax.BeginForm() is this then MvcAjax or Jquery?</p> </blockquote> <p>By default it is jquery. You need to reference the <code>jquery.unobtrusive-ajax.js</code> script for this to work.</p> <blockquote> <p>Or would I use Html.BeginForm() and register something like $.post on the click event of the Form.</p> </blockquote> <p>That's an alternative. Personally that's what I do.</p> <blockquote> <p>I assume that it is correct, that I am posting to the create action of the commentscontroller and I would use the JsonModelBinder to transform it to a model. After that I would return Json and would append it to my comments list...</p> </blockquote> <p>The JsonModelBinder has been introduced in ASP.NET MVC 3 and it allows you to send a JSON string to a controller action which will be mapped back to a view model. For example if you have the following view model:</p> <pre><code>public class PersonViewModel { public string Name { get; set; } public int Age { get; set; } } </code></pre> <p>and the following action:</p> <pre><code>public ActionResult Foo(PersonViewModel person) { ... } </code></pre> <p>the traditional way to invoke it in AJAX is:</p> <pre><code>$.ajax({ url: '@Url.Action("foo")', type: 'POST', data: { name: 'john', age: 20 }, success: function(result) { // TODO: } }); </code></pre> <p>and in ASP.NET MVC 3 you could send a JSON as request parameter which will be bound to the <code>PersonViewModel</code> action parameter:</p> <pre><code>$.ajax({ url: '@Url.Action("foo")', type: 'POST', contentType: 'application/json', data: JSON.stringify({ name: 'john', age: 20 }), success: function(result) { // TODO: } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload