我正在通过URL正确传递我的论点,然后我不知道变量有什么问题
消息:缺少Welcome :: index()
的参数1文件名:controllers / Welcome.php
行号:10
回溯:
文件:/var/www/html/proyecto/application/controllers/Welcome.php线: 10功能:_error_handler
文件:/var/www/html/proyecto/index.php行:292功能: require_once
控制器:
class Welcome extends CI_Controller {
function __construct(){
parent::__construct();
$this->load->model('login_model');
}
public function index($password){
$this->load->view('header');
$this->load->view('index');
}
}
答案 0 :(得分:0)
你需要将pariable传递给查看页面吗?然后使用此代码
class Welcome extends CI_Controller {
function __construct(){
parent::__construct();
$this->load->model('login_model');
}
//value of password fetch to the variable $password
//eg:$password='123';
public function index($password){
$this->load->view('header');
$this->load->view('index',$password);
}
}
答案 1 :(得分:0)
您的控制器需要接受一个参数
public function index(**$password**)
因此您需要定义来自的$password
。
或者您只需编辑控制器
public function index($password = "")
避免警告。
答案 2 :(得分:0)
$(document).ready(function() {
$(".dropdown-menu li a").click(function(e){
e.preventDefault(); //this is the line which prevents the event
$(this).parents(".dropdown").find('.btn').html($(this).text() + ' <span class="caret"></span>');
$(this).parents(".dropdown").find('.btn').val($(this).data('value'));
//this is the code to post the value to server
$.post("YourPHPMethod.php",{name: $(this).text()} ,function(response){
alert("Response from server: "+response);
});
});
谢谢天使和怪人
答案 3 :(得分:0)
您应该检查您要求的网址。您可能会在“将URI段传递给您的函数”部分中看到reference here。
class Welcome extends CI_Controller {
function __construct(){
parent::__construct();
$this->load->model('login_model');
}
public function index($password){
$this->load->view('header');
$this->load->view('index');
}
}
从上面的代码中,为每个请求创建一个必需的$ password变量。因此,您必须在您的网址末尾添加一个值作为密码。 即example.com/index.php/Welcome/index/password
我希望这有帮助。谢谢。