我使用 Silex Frame Work,我正在尝试使用以下代码删除表中列出的后端文件,但是火错误给了我一条错误消息“无效的正则表达式标志 a”,当我点击删除链接时,它会转到一个白页。代码是:
<script type="text/javascript">
$(document).ready(function(){
$(".delete-file").live('click', function() {
itemRow = $(this).parent().parent().parent();
fileId = $(this).attr('file_id');
deleteURL = $(this).attr('href');
var html = "<div> Are you sure, you want to DELETE this file? </div>";
var dialog = $(html).dialog({
buttons: {
"Ok": function() {
$.ajax({
url : deleteURL,
type : 'DELETE',
success : function(data) {
itemRow.remove();
dialog.dialog("close");
},
error : function() {
dialog.dialog("close");
}
});
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
return false;
});
});
</script>
我使用:
{% for row in result %}
<tr class="content {{ cycle(['odd', 'even'], loop.index) }}">
<td> {{ row.name }} </td>
<td> {{ row.user.username }} </td>
<td class="url"> <a href="{{ path('info', {"id" : row.file_id}) }}">{{ row.path | truncate(30) }}</a> </td>
<td> <img src="{{conf('base_url')}}/{{row.thumbnail}}"/> </td>
<td class="url"> {{ row.size | bytes_format}} </td>
<td> {{ row.description }} </td>
<td>
<span><a href="{{ path('delete', {'id' : row.file_id} ) }}" class="delete-file" file-id="{{row.file_id}}">DELETE</a></span>
</td>
</tr>
{% endfor %}