javascript - 我在 codeigniter 中遇到错误

标签 javascript php ajax codeigniter

通常在核心 php 中,如果我们尝试使用 ajax 发出请求,我们会设置存在查询的文件的 url,因此当在 codeigniter 中切换相同进程时,但我得到一个响应错误,任何人都可以帮助我解决这个错误

网络::ERR_SSL_PROTOCOL_ERROR

这是我的代码 Javascript ajax

$.ajax ({
                type     : "POST",
                url      : "https://localhost:90/tufuturo/home/register",
                data     : {username: username, email: email, password: confirm_password},
                dataType : "text",
                success  : function(data, text, xhr) {
                    if(xhr == 200) {
                        var return_data = data;
                        $('#messagebox').fadeIn(2000, function() {
                            $(this).html("<div class='message'>"+return_data+"</div>").delay(4000).fadeOut(3000);
                        });
                    }
                }
            });

这是我的 Home.php Controller 的代码

public function register() {
        $this->load->library('form_validation');
        $this->form_validation->set_rules('username', '', 'required|trim|is_unique[users.username]');
        $this->form_validation->set_rules('password', '', 'md5|trim');

        if($this->form_validation->run()) {
            $data = array(
                'username'   => $this->input->post('username'),
                'password'   => $this->input->post('password'),
                'email'      => $this->input->post('email'),
                'type'       => 'user'
            );

            $this->data_insert->add_admin($data);
            echo 'New admin has been successfully created';
        } else {
            echo 'Username already taken';
        }
    }

请让我知道如何摆脱这个错误

最佳答案

您的本地主机不符合 https 协议(protocol)

https://localhost:90/tufuturo/home/register 更改 url 到 http://localhost:90/tufuturo/home/register

如果你想使用https协议(protocol)你需要generate certificate

关于javascript - 我在 codeigniter 中遇到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37270456/

相关文章:

ruby-on-rails - 简单的 AJAX 示例

Javascript 初学者 - 全局变量不起作用

javascript - 为什么我的 json 对象的 `email` 属性不会显示在我的 jade 模板中?

javascript - 为类中的每个元素添加一个<hr/>元素,得到[Object object]或纯文本而不是hr元素

javascript - CSS 转换未在所有浏览器中使用 jQuery 更新

php - 如何从 laravel session 中的单个命令中删除多个键

php - 使用 PHP 将网页连接到数据库会产生奇怪的结果

php - jQuery/PHP 用于顶部通知栏,将所有页面内容向下推

ajax - Angular Datatables 使用源对象

javascript - TinyMCE 不启动 ajax 加载的文本区域