Codeigniter:页面背景在提交时无法加载错误


Codeigniter: page background won't load upon submit error

我有一个登录页面,其中包括一个简单的js文件,将加载<body>背景图像。如果我只是打开这个登录页面,一切工作正常。但是当发生登录错误或注册错误时,页面将不会加载背景图像。在欢迎控制器中像这样加载登录页面:

public function index()
{
    $this->load->view('index');
}

和相同的页面加载到login/register控制器中,如下所示:

   if ($this->form_validation->run() == FALSE)
   {
        // validation fail
        $data = array(
            'error_message' => 'Please check your inputs.'
        );
        $this->load->view('index', $data);
   }

我确实注意到,当提交错误发生时,重新加载的索引页的url是http://localhost:8080/cashflow/index.php/login/index而正常的索引页url应该是http://localhost:8080/cashflow/index.php

那么,我怎么能有js文件运行,使背景图像将被加载。

谢谢,

也许您必须检查您的jsimages文件的url路径。

你找到你的js正确的地方吗?就像:

<script url="<?php echo base_url('path/to/js.js');?>"></script>

请注意,当您访问链接//localhost:8080/cashflow/index.php/login/index路径时,js文件的路径与访问链接//localhost:8080/cashflow/index.php的路径相同。

这样,你应该检查body标签中设置的images背景的url路径,它是否像style="background: url(/path/to/background.jpg) center top norepeat;" ?

请注意,路径必须指向您选择的imagejs