title: How to pass element from model in ajax post request?
body: <p>First of all sorry for my English. </p>
  
  <p>I have no idea how to upload element from the model (var nameData in )using AJAX . I asked for a hint, here is the code:</p>
  
  <p>View:</p>
  
  <pre><code>&lt;tbody&gt;
      @foreach (var item in (Model.files))
      {
  
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;h4&gt;@item&lt;/h4&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;input type="button" id="sendCodesToDB" class="btn btn-success" value="Insert codes in DB" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      }
  &lt;/tbody&gt;
  </code></pre>
  
  <p>and script:</p>
  
  <pre><code>&lt;script&gt;
  $('#sendCodesToDB').on('click', function () {
  
      var nameData = //Here I am trying to put: @item.Name;
  
      $.ajax({
          url: '/Home/Foo',
          type: 'POST',
          dataType: 'json',
          cache: false,
          data: nameData,
          success: function (dataFromAction) {
              $('#idTextu').val(dataFromAction);
          }
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>UPDATE</strong> </p>
  
  <p>I tried to apply your tips, my code now:</p>
  
  <p>Controller:</p>
  
  <pre><code>    [HttpPost]
      public ActionResult InsertCodesToDB(string name)
      {
          cl.InsertCodesToDB(name);
          fl.MoveCodeFileToAccept(name);
  
          string response = "Test";
          return Content(response, "application/json");  
      }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;input type="button" class="btn btn-success sendCodesToDB" value="Insert Codes in DB" data-value="@item.Name"/&gt;
  </code></pre>
  
  <p>Script:</p>
  
  <pre><code>$('.sendCodesToDB').on('click', function () {
  
      var name = $(this).data("value");
  
      $.ajax({
          url: '/ActualCodes/InsertCodesToDB',
          type: 'POST',
          dataType: 'json',
          cache: false,
          data: name,
          success: function (response) {
               @(ViewBag.MessageOK) = response;
          },
          error: function () {
              onBegin;
          }
      });
  });
  </code></pre>
  
  <p>But unfortunately the currently pressing button sendCodesToDB dont work. I caught up in Controller and Action is not called. 
  Where I have problem ? </p>