小编Afs*_*sar的帖子

Fetch -API 返回 HTML 而不是 JSON

我有一个 Spring REST API,我已经在 Postman 上测试过它,它返回完全有效的 JSON。但是,当我在前端 React 代码上调用相同的 API 时,它会返回 HTML。这是函数,我用来调用 API,

export function run(engine, mediaId, owner, target, access){
  let url = engine + "/" + mediaId + "?id=" + owner + "&targetId=" + target + "&access=" + access;

  return fetch(full_url, { credentials: "include",
                           headers: {
                             "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
                          }})
    .then((response) => {

      return response.json();})
    .then((data) => {
        console.log(data);

    })
    .catch((error) => {
        console.log(error);
    });
}
Run Code Online (Sandbox Code Playgroud)

我在此调用中遇到语法错误Unexpected token < Thus when I check using response.text()我可以看到返回的数据是 HTML 而不是 …

javascript json fetch-api

11
推荐指数
2
解决办法
3万
查看次数

将ArrayList转换为JSONArray

这是我的ArrayList

ArrayList< HashMap < String,String> > list =  new ArrayList<>();
Run Code Online (Sandbox Code Playgroud)

它包含hashmap.

如何获取Plain JSONArray中的所有哈希映射?

arrays json arraylist hashmap

3
推荐指数
1
解决办法
8095
查看次数

通过javascript将表格html导出到文本和图像中

我的问题是图像!!!!我将此表的 html 导出到 excel,但图像未导出到表中。

   <table class="order-table table sortable" id="tableadmin">
    <thead>
        <tr>
            <th style="width:8px; min-width:8px; max-width:8px;">ID</th>
            <th>Télépro</th>
            <th>Date RDV</th>
            <th>Heure RDV</th>
            <th>Fiche</th>
            <th style="width:170px; min-width:170px; max-width:170px;">Compterendu</th>
            <th style="width:250px; min-width:250px;">Commentaire commercial</th>
        </tr>
    </thead>
    <tbody id="changetable" class="new">
        <tr>
            <td>
                <?php echo $id ?>
            </td>
            <td>
                <?php echo $login ?>
            </td>
            <td>
                <?php echo $date ?>
            </td>
            <td>
                <?php echo $heure ?>
            </td>
            <td><img src="../img/fiche.png" />
            </td>
            <td>
                <?php echo $compterendu ?>
            </td>
            <td>
                <?php echo $comment ?>
            </td>
        </tr>
    </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
我的问题是图像!!!!

html javascript php

0
推荐指数
1
解决办法
5057
查看次数

标签 统计

javascript ×2

json ×2

arraylist ×1

arrays ×1

fetch-api ×1

hashmap ×1

html ×1

php ×1