How to add a value sent from an onclick to the Ajax 'date'?

1

I have a table in HTML and in a table column there is a link that opens a Modal. In this way I make approval records and show who approved and the date of approval (more than one person can approve, so he has a list of approvals). To do the registration I need Id Request and IdEmpresa and to list only I need Id Id. And I'm in this situation:

Table Column:

    '<td class="cell-action" data-idsolicitacao="@(solicitacao.IdSolicitacao)" data-toggle="modal" data-target="#SolicitacoesModal" style="cursor:pointer"><a onclick="$('#IdSolicitacao').val(@solicitacao.IdSolicitacao);$('#IdEmpresa').val(@solicitacao.IdEmpresa);">Histórico</a></td>'

Modal:

<div class="modal-content">
  <div class="modal-body">
      @using (Html.BeginForm("CreateSolicitacao", "Solicitacoes", FormMethod.Post))
      {
      <input hidden="hidden" id="IdSolicitacao" name="IdSolicitacao"/>
      <input hidden="hidden" id="IdEmpresa" name="IdEmpresa" />
      <div class="content-header col-md-8 controls">
          <h4 class="modal-title" id="aprovacoes">APROVAÇÕES</h4>
      </div>
      <div class="content-header col-md-4 controls">
         <h4 class="modal-title" id="historico">HISTÓRICO</h4>
          <div id="conteudoHistorico"></div>
          <script type="text/javascript">
              var item = "";
              $.ajax({
                  type: 'POST', 
                  url: "@Url.Action("_ListaHistorico", "Solicitacoes")", 
                  data: { IdSolicitacao: id },
                  dataType: 'JSON', 
                  success: function (result) {
                      for (var i = 0; i <= result.length; i++) {
                          var item = result[i];
                          $("#conteudoHistorico").append(
                                          "  <div>DataCadastro: " + item.DataCadastro + "</div>" +
                                          "  <div>Nome: " + item.UsuarioNome + "</div>" +
                                          "  <div>Observacao: " + item.Observacao + "</div>" 
                                          );
                        }
                  },
                  error: function (result) {
                      alert("ERRO!");
                  }
              });
          </script>
      </div>
          <div id="conteudoAprovacoes" class="col-md-8 controls">
                  @Html.RadioButton("Situacao", true, true)
                  @Html.Label("Aprovar")
                  @Html.RadioButton("Situacao", false)
                  @Html.Label("Reprovar")
                  <br />
                  <br />
                  @Html.SolyosTextArea("Observacao", "col-md-12 controls", "Digite o motivo, ou alguma observação")
                  <br />
                  <br />
                  <br />
                  <br />
                  <div class="form-edit-footer" style="padding-right: 15px;">
                      <input type="submit" value="SALVAR" onclick=""/>
                      <input type="button" data-dismiss="modal" value="Cancelar" onclick="Solyos_Modal_Form_Close();" />
                  </div>

            </div>
      }
  </div>

In the onclick of td , I can set the IdSolicitation and the IdEmpresa in inputs hidden to make the registration, but I can not access IdSolicitation to play on the Ajax date. How can I do this?

EDIT

I solved the problem as follows:

I added onclick a function calling my Ajax

<td class="cell-action" data-idsolicitacao="@(solicitacao.IdSolicitacao)" data-toggle="modal" data-target="#SolicitacoesModal" style="cursor:pointer"><a onclick="$('#IdSolicitacao').val(@solicitacao.IdSolicitacao);$('#IdEmpresa').val(@solicitacao.IdEmpresa); GetHistorico()">Histórico</a></td>

And in the script:

<script type="text/javascript">
 function GetHistorico() {
              var item = "";
              $.ajax({
                  type: 'POST', 
                  url: "@Url.Action("_ListaHistorico", "Solicitacoes")", 
                  data: { IdSolicitacao: $('#IdSolicitacao').val() },
                  dataType: 'JSON', 
                  success: function (result) {
                      for (var i = 0; i <= result.length; i++) {
                          var item = result[i];
                          $("#conteudoHistorico").append(
                                          "  <div>DataCadastro: " + item.DataCadastro + "</div>" +
                                          "  <div>Nome: " + item.UsuarioNome + "</div>" +
                                          "  <div>Observacao: " + item.Observacao + "</div>" 
                                          );
                        }
                  },
                  error: function (result) {
                      alert("ERRO!");
                  }
              });
}
          </script>
    
asked by anonymous 20.03.2014 / 15:24

1 answer

1

In the javascript ajax, do so

$.ajax({
    type: 'POST', 
    url: "@Url.Action("_ListaHistorico", "Solicitacoes")", 
    data: { IdSolicitacao: $("#IdSolicitacao").val(), IdEmpresa: $("#IdEmpresa").val() },
    dataType: 'JSON', 
//.....
    
20.03.2014 / 15:29