如何在codeigniter控制器中使用javascript



js_class.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class js_class extends CI_Controller
{
public function __construct() {
parent::__construct();
$this->load->library('javascript');
$this->load->library('javascript/jquery');
$this->load->library('session');
$this->load->helper(array( 'form', 'url' ));
$this->load->helper('url');
$this->load->database();
$this->load->library('form_validation');
$this->load->library('pagination');

}

public function index() {
$data['library_src'] = $this->jquery->script();
$data['click'] = $this->jquery->_click('#click', "alert('Hello! You Click the button');");

$this->load->view('js_class_view', $data);
}
}
?>

配置.php

$config['javascript_location'] = 'http://localhost/test/assets/js/jquery.min.js';

当我编译代码时发生错误,说对受保护方法的调用CI_jquery::_click()。如果您遇到并解决了此类问题,请帮助我

请更正此代码

$data['click'] = $this->jquery->_click('#click', "alert('Hello!您单击按钮'("(;

以删除此"警报"上的";"('您好!你点击按钮'(;"代码

最新更新