-2

ok I figured out the jquery part but not the parameters of them all can anyone help figure out the parameters for each url string?

this is the jquery I figured out! also would this work better then what the below answer?

$.get('adminajax.php', {'action':'getUsers'}, function(data){ $('#users .users').html(data); });

He sent me this in an email:

You can specify a page by adding: p=[page #] You can specify a file and it will add a checkbox next to the user which will be checked if the user has permission to download: file=[file location]

adminajax.php?action=createDirectory&directory=[new directory location]

adminajax.php?action=setAvailability&user=[username]&file=[filelocation]&available=[true or false]

I'm trying to get it to display in these html tags:

<div id="files">
    <b>Files:</b>
    <ul class="files"></ul>
</div>

<div id="file_options">
    <b>Options:</b>
</div>

<div id="users">
    <b>Users:</b>
    <ul class="users"></ul>
</div>
4

1 回答 1

1

您正在尝试做的是 Ajax 调用。这是一个例子:

$.ajax({
  type:'GET',
  url:'adminajax.php',
  data: {action:'getDirectory', directory:'directoryNameHere'},
  success: function (response) {
    //here the response is the stuff that the server replied with
    var json = $.parseJSON(response); //if the server returned JSON you need to parse it
    //do stuff with that data
  } 
});

这是第一个获取文件的示例的代码。针对其他示例进行相应调整。

服务器响应应该在成功函数中可用。尝试安慰它以查看您从中得到了什么,如果它是 JSON,则需要首先对其进行解析。

所有示例的 Url 似乎都相同,只有操作和其他参数在变化,因此对于其他调用,您只需更改 ajax 调用的数据属性。

为了获取用户,您的数据对象只是动作,没有其他参数:

data: {action: 'getUsers'}

用于创建目录:

data: {action:'createDirectory', directory: 'nameOfDirectoryHere'}

正如 charlietfl 在评论中指出的那样,如果将 dataType: 'json' 放在 ajax 调用中,则不需要执行 $.parseJSON。(如果数据当然是 JSON)。

于 2013-10-28T02:48:57.220 回答