有沒有辦法區分ajax調用和正常的瀏覽器請求在PHP(或codeigniter是具體的)?如何在php(或codeigniter)中區分ajax調用和瀏覽器請求?
這是我的jquery ajax調用:
$(document).ready(function() {
$('#container').load('http://localhost/index.php/customer/');
});
這是客戶控制器的笨指數方法:
public function index() {
//if (call == 'ajax request')
// do this if it's an ajax request;
//else
// do that if user directly type the link in the address bar;
$this->load->view('customer/listview');
}
任何幫助,將不勝感激。謝謝。
哇,它的工作原理。我猜測我沒有徹底讀過輸入類。非常感謝。 – dqiu