我有一個AJAX調用。我需要傳遞一些參數給我的函數。這是我的AJAX調用。如何在ajax調用中發送參數
$.ajax({
url: 'lib/function.php',
data: {
action: 'getStoreSupplyItems',
id: store_id,
indent: 1
},
success: function(output) {
//alert(output);
$('#response').html(output);
}
});
這裏是我的後端函數的定義,我想呼籲:
function getStoreSupplyItems($category = '')
{
global $db;
$data = $_REQUEST;
$category = (!empty($category) ? ' AND cim.item_group_code IN ("'.$category.'") ' : '');
if ($data['id'] != "")
{
$store = $data['id'];
}
else
{
$store = $_SESSION['user']['store']['id'];
}
我怎麼能傳遞一些參數的功能?我想要傳遞的參數就像'12,5,6'。
你能更具體的你需要什麼? –
只需將另一個屬性添加到您提供給'data'的對象......? –
@Rory McCrossan:這是一個解決方案。但是如果這樣做,我需要在後端更改$ category的條件。它會影響其他一些功能。 – django