1

Trying to find the equivalent for this Ajax function in using jQuery this is the ajax code that i want to convert over.

new Ajax.Updater('folder', 'ajax/get_folders.php', {
parameters: { category: #$F('category'), office: #$F('office') } 

This is what I have so far.

$.ajax({
url:'ajax/get_folders.php',
data: { category: $('#category').val(), office: $('#office').val() }
});

Not sure what to do with the item 'folder' in the original ajax call. That updates the options in a select on a form for the website. This is the only part of the code that has stumped me so far.

4

1 回答 1

1

您可以订阅success回调并更新相应 DOM 元素的内容:

$.ajax({
    url: 'ajax/get_folders.php',
    data: { category: $('#category').val(), office: $('#office').val() },
    success: function(result) {
        $('#folder').html(result);
    }
});

或简单地使用以下load功能:

var parameters = { 
    category: $('#category').val(), 
    office: $('#office').val() 
};
$('#folder').load('ajax/get_folders.php', parameters);
于 2013-06-11T13:35:18.807 回答