奇怪的行为,WAMP-代码点火器


Strange behaviour, WAMP - Codeigniter

背景:我将Codeigniter项目从Windows 7迁移到Windows 10,在Windows 7中,我手动安装Apache、PHP和Mysql,但在Windows 10中我安装了WAMP。这里需要注意的是,mysqli在这个新设置中不起作用,我在这里尝试了很多事情并提出了问题,但都没有用。所以我现在正在使用mysql。

问题:我开始测试网站的功能(迁移的项目),发现注册不起作用,这在Windows7设置中运行良好。表单正在提交给保存表单html的同一控制器。当用户单击提交按钮时,jquery会执行一些操作,然后返回true以提交表单。

问题是,控制器确实会响应表单提交而加载,但没有发布数据,但如果我将操作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;

$( '#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目录中),它就工作了。