如何Ajax启用此代码? [英] How to Ajax-Enable this Code?
问题描述
我有两个PHP文件来管理服务器上的文件:
list.php
delete.php
文件list.php显示服务器特定目录中的文件列表。它使用表来列出文件。表中的一列名为删除此文件。如果您在一行中单击该列,则文件delete.php将被删除。将调用一个参数。它将删除通过地址栏参数传递给它的文件。
这是一个简单的例子list.php
I have two PHP files to manage my files on a server:
list.php
delete.php
The file "list.php" shows a list of files in a specific directory of server. It uses a table to list the files. One of the columns in the table is named "Delete this file". If you click on that column in a row, the file "delete.php" with an argument will be called. It will delete the file passed to it through address bar arguments.
This is an easy example of "list.php"
推荐答案
如何使用AJAX或JQuery执行此操作?
How can I do this with AJAX or JQuery?
jQuery只是一组预定义的JavaScript函数(= library)。除此之外,jQuery和JavaScript之间没有区别。
AJAX只是一种设计模式(使用特殊对象),但就是这样。您可以将其想象为后台HTTP请求。
jQuery is just a predefined set of JavaScript functions (= library). other than that there is no difference between jQuery and JavaScript.
AJAX is merely a kind of Design Pattern (which uses a special object), but that?s it. you can imagine it as a background HTTP Request.
如何将此代码更改为启用Ajax的代码。我想点击删除按钮柱。然后它应该运行delete.php。其背后的论据没有刷新当前的list.php页。删除文件后,我可以使用JavaScript函数删除当前列的当前行。
How can I change this code to an Ajax-enabled one. I wish to click on the "Delete" column. It should then run "delete.php" with its arguments behind the scene without refreshing the current "list.php" page. When the file was deleted, I can use a JavaScript function to delete the current row of the current column.
这就是你怎么做的。只是读了一些不太旧的AJAX教程来掌握它。
注意:我使用头来传达删除成功(如果删除成功,则使用HTTP 200或204)如果删除失败,则为HTTP 500)
that?s exactly how you would do it. just read some not too old AJAX tutorials to get the hang of it.
note: I?d use headers to communicate the deletion success (i.e. HTTP 200 or 204 if the deletion succeeded and a HTTP 500 if the deletion failed)
我认为以下函数应该包含在< HEAD>中页面标签:
I think the following function should be included in the <HEAD> tag of the page:
它是一个开始,但不会带给你更多。 (它与范围有关)。
a略微更有利的功能*将是:
it?s a start, but won?t bring you further. (it has something to do with scope).
a slightly more advantageous function* would be:
这篇关于如何Ajax启用此代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!