奇怪的行为,WAMP-Codeigniter [英] Strange behaviour, WAMP - Codeigniter

查看:97
本文介绍了奇怪的行为,WAMP-Codeigniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:我将Codeigniter项目从Windows 7迁移到Windows 10,在Windows 7中,我正在手动安装Apache,PHP,Mysql,但是在Windows 10中,我安装了WAMP.这里要指出的是,mysqli在此新设置中不起作用,我在这里尝试了很多事情并提出了问题,但无济于事.因此,我目前正在使用mysql.

Background : I migrated a Codeigniter project to Windows 10 from Windows 7, in Windows 7, I was working with manual installation of Apache, PHP, Mysql but in Windows 10 I installed WAMP. Point to be noted here is that the mysqli is not working in this new setup, I have tried many things and asked questions here but to no avail. So I am working with mysql at the moment.

问题:我开始测试网站(迁移的项目)的功能,发现注册不起作用在Windows 7安装程序中正常运行.将该表单提交到保存html表单的同一控制器.当用户单击提交"按钮时,jquery会做一些事情,然后返回true以使表单得以提交.

Problem : I started testing functioning of the website(migrated project) and found that the signup is not working which was working perfectly in windows 7 setup. The form is being submitted to the same controller which holds the form html. When the user clicks the submit button, the jquery do some stuff then returns true to let the form be submitted.

问题在于,控制器确实响应于表单提交而被加载,但是没有发布数据,但是如果我将操作URL更改为测试脚本,则表明表单正在正确提交还有帖子数据.

在application/config/routes.php中重新路由:

$route['(?i)Signup/(:any)'] = 'Signup/index/$1';

控制器:

public function index ( $key = NULL )
{
    /** Does nothing */
    if ($_SERVER['REQUEST_METHOD'] == 'POST') print_r($_POST);

    if (  isset ( $key )  )
    {
       return $this->_key( $key );
    }
    /** Register. */
    if (   $this->input->post ( 'register_user' )  )
    {
        echo 'register_user';
        return $this->_register (  );
    }
    /** File upload Ajax call. */
    else if (  ! $this->input->post ( 'register_user' )  &&  $this->input->post ( 'gender' ) && $this->input->post ( 'ajaxUpload' )  )
    {
        echo 'ajaxUpload';
        echo $this->_upload (  );
    }
    /** Email Validation Ajax Call. */
    else if (  ! $this->input->post ( 'register_user' )  &&  $this->input->post ( 'email_validation' )  &&  $this->input->post ( 'email' )  )
    {
        echo 'email_validation';
        echo $this->_email_available (  );
    }
    /** Default view. */
    // If I submit form or not, this section is what gets executed
    else 
    {
        echo 'else';
        $this->_default (  );
    }
}

查看文件:

<form id="sign_up" action="<?php echo site_url (  ) . $this->router->fetch_class (  ) ;?>" method="post" accept-charset="utf-8" enctype="multipart/form-data">
    <input id="register_user" type="hidden" name="register_user" value="Submit" />
    ---
    ---
    <button type="submit" name="register_user" id="register_user" value="Submit">Submit</button>
</form>

JavaScript文件: var sentinel = false;

JavaScript File : var sentinel = false;

$( '#sign_up' ).submit ( function ( event ) {
    if ( ! sentinel )
    {
        var scriptUrl = $ ( '#sign_up' ).attr ( 'action' );
        var data = new FormData (  );
        /* Appaend form data with the formData object */
        ---
        ---

        $.ajax ( {
            method : 'POST', url : scriptUrl, data : data, cache : false, processData: false, contentType: false, dataType : 'json',
            success : function ( data, textStatus, jqXHR ) { 

                /** Success uploading file, File saved to the server and server did not set the data.error variable/key. */
                if ( typeof data.error === 'undefined' )
                {
                    /** DO stuff */

                    sentinel = true;
                    $( '#sign_up' ).submit (  );
                }
                else
                {
                    /** Set error message and do nothing. */
                }
            },
            error : function ( jqXHR, textStatus, errorThrown ) 
            {
                alert (  jqXHR.responseText  );
            }

        } );
    }

    // return false - cancels original submits until allowed
    // returns true - allows a triggered submit
    return sentinel;
}

推荐答案

问题出在mod_rewrite上.一旦取消注释Apache的httpd.conf文件中的LoadModule rewrite_module modules/mod_rewrite.so行的位置,如果安装了Apache,它将驻留在conf目录中.

The problem was with mod_rewrite. Once I uncommented the line LoadModule rewrite_module modules/mod_rewrite.so in Apache's httpd.conf file, which resides in the conf directory if the Apache install, it worked.

这篇关于奇怪的行为,WAMP-Codeigniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆