1

文字列の配列を作成する MVC は

  public JsonResult GetInvalidFilesAJAX(JQueryDataTableParamModel param)
    {
        string[] invalidFiles = new string[] { "one.xls", "two.xls", "three.xls" };

        return Json(new
        {
            Status = "OK",
            InvalidFiles = invalidFiles
        });
    }

そして、ループして各文字列を出力する JavaScript は次のとおりです。

  $.ajax(
                          {
                              type: 'POST',
                              url: 'http://localhost:7000/ManualProcess/GetInvalidFilesAJAX',
                              success: function (response) {
                                  if (response.Status == 'OK') {
                                      //Use template to populate dialog with text of Tasks to validate
                                      var results = {
                                          invalidFiles: response.InvalidFiles,
                                      };
                                      var template = "<b>Invalid Files:</b> {{#invalidFiles}} Filename: {{invalidFiles.value}} <br />{{/invalidFiles}}";
                                      var html = Mustache.to_html(template, results);

                                      $('#divDialogModalErrors').html('ERROR: The following files have been deleted:');
                                      $('#divDialogModalErrorFiles').html(html);

配列内の文字列を参照するにはどうすればよいですか? 上記の方法は正しくありません。私が見つけたすべての例は、Jason コレクションにプロパティ名がある場合のようです..私の場合、それは単なるキーと値のペアです (私は推測しますか?)

4

1 に答える 1