使用ajax请求成功返回的数据替换下面代码中的imge_list <div class="row"> {% for imge in imge_list %} {% if not class_name or imge.class_name == class_name %} <div class="col-md-6" id="imge_id" style="width: 310px"> <div class="thumbnail"> <p></p> <form action="{% url 'delete_image' %}" method="POST"> {% csrf_token %} <input type="hidden" name="image_id" value="{{ imge.id }}"> <button type="submit" class="btn btn-sm pull-right" id="delete-button">删除</button> </form> <span class="label label-primary" style="font-size: 20px;">类别</span> <span style="font-size: 20px;">{{ imge.class_name }}</span> <span class="label label-success pull-right" style="font-size: 5px;">{{ imge.confidence }}</span> <p></p> <img src="{{ imge.result_image }}" class="img-rounded" alt="..." height="300px" width="300px"> <span class="label label-info">坐标(xywh):</span> <br>{{ imge.location }}<br> <span class="label label-danger">消耗时间:</span> {{ imge.comsume_time }}<br> <span class="label label-success">预测日期:</span> {{ imge.create_time|date:"Y-m-d:h:i:s" }} </div> </div> {% endif %} {% endfor %} </div>
时间: 2023-06-16 14:05:26 浏览: 178
Assuming that the returned data is a list of image objects, you can use the following code to replace the existing code:
```
<div class="row" id="imge_list">
{% for imge in imge_list %}
{% if not class_name or imge.class_name == class_name %}
<div class="col-md-6" id="imge_id" style="width: 310px">
<div class="thumbnail">
<p></p>
<form action="{% url 'delete_image' %}" method="POST">
{% csrf_token %}
<input type="hidden" name="image_id" value="{{ imge.id }}">
<button type="submit" class="btn btn-sm pull-right" id="delete-button">删除</button>
</form>
<span class="label label-primary" style="font-size: 20px;">类别</span>
<span style="font-size: 20px;">{{ imge.class_name }}</span>
<span class="label label-success pull-right" style="font-size: 5px;">{{ imge.confidence }}</span>
<p></p>
<img src="{{ imge.result_image }}" class="img-rounded" alt="..." height="300px" width="300px">
<span class="label label-info">坐标(xywh):</span> <br>{{ imge.location }}<br>
<span class="label label-danger">消耗时间:</span> {{ imge.comsume_time }}<br>
<span class="label label-success">预测日期:</span> {{ imge.create_time|date:"Y-m-d:h:i:s" }}
</div>
</div>
{% endif %}
{% empty %}
<p>No images found.</p>
{% endfor %}
</div>
```
You will need to make sure that the returned data is in the correct format and that the `imge_list` variable is properly updated with the new data. You should also add an `id` attribute to the `div` element that contains the image list (`<div class="row" id="imge_list">`) so that you can reference it in your AJAX call.
阅读全文