title: Uncaught SyntaxError: Unexpected token S in JSON at position 5
body: <p>How can I solve this error?<br />
  And how can I define a variable in the AJAX function and use it outside of the AJAX function?</p>
  <p>cshtml:</p>
  <pre><code>    var file_name = '';
                              
      var inputs = document.getElementById(transaction_attribute[i].sam_key);
      var files = inputs.files;
      var formData = new FormData();
      
      for (var l = 0; l != files.length; l++) {
          formData.append(&quot;files&quot;, files[l]);
      }
      $.ajax(
      {
        url: '@Url.Action(&quot;IndexMy&quot;)',
        data: formData,
        processData: false,
        contentType: false,
        type: &quot;POST&quot;,
        success: function (data) {                                        
           console.log(data);
           **var file_name = JSON.stringify(data).toString();**
        }
      }
      );
      obj_table_transaction.id **= file_name;**
      obj_table_transaction.text = $('#' + 
   transaction_attribute[i].sam_key).val().split(&quot;\\&quot;).pop();
      table_transaction.push(obj_table_transaction);
      obj_table_transaction = {};
  </code></pre>