1 回答

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超10個(gè)贊
您通常會(huì)在 javascript 端使用 AJAX 調(diào)用來(lái)執(zhí)行此操作:
$.get('/path/to/file.php', function (result) {
console.log(result); // do something with result returned
}
然后在php方面:
<?php // /path/to/file.php
// perform your query, set variables
if ($success) {
echo json_encode([
'status' => 'success',
'html' => '<option value='.$companies['companyName'].'>'.$companies['companyName'].'</option>'
]);
}
echo json_encode([
'status' => 'error',
'message' => 'Something went wrong, handle this'
]);
- 1 回答
- 0 關(guān)注
- 106 瀏覽
添加回答
舉報(bào)