首页 > 解决方案 > PHP 代码在本地工作,但无法正确运行 Web 服务器

问题描述

我有一个来自在本地服务器上运行的客户端的代码。索引页面显示背景和表格,但在在线服务器上它只显示背景图像,没有其他内容

这是 index.php 脚本:

<?php include('header.php'); ?>

  <body id="login">
    <div class="container">

      <form id="login_form" class="form-signin" method="post">
        <h3 class="form-signin-heading"><i class="icon-lock"></i> Please Login</h3>
        <input type="text" class="input-block-level" id="usernmae" name="username" placeholder="Username" required>
        <input type="password" class="input-block-level" id="password" name="password" placeholder="Password" required>
        <button name="login" class="btn btn-info" type="submit"><i class="icon-signin icon-"></i> Sign in</button>      
              </form>

<script>
            jQuery(document).ready(function(){
            jQuery("#login_form").submit(function(e){
                    e.preventDefault();
                    var formData = jQuery(this).serialize();
                    $.ajax({
                        type: "POST",
                        url: "login.php",
                        data: formData,
                        success: function(html){
                        if(html=='true')
                        {
                        $.jGrowl("Welcome to Thutoboswa Learning Management System", { header: 'Access Granted 😀 #WearAMask😷' });
                        var delay = 2500;
                            setTimeout(function(){ window.location = 'dashboard.php'  }, delay);  
                        }
                        else
                        {
                        $.jGrowl("Please Check your username and Password", { header: 'Login Failed' });
                        }
                        }                       
                    });
                    return false;
                });
            });
            </script>
    </div>    
    
    <!-- /container -->
<?php include('script.php'); ?>
</body>
</html>
  

Mozilla Firefox 控制台显示以下警告:

This page uses the non standard property “zoom”. Consider using calc() in the relevant property values, or using “transform” along with “transform-origin: 0 0”. gobojangojss.co.bw

Using //@ to indicate sourceMappingURL pragmas is deprecated. Use //# insteadjquery-1.9.1.min.js:2:21

Layout was forced before the page was fully loaded. If stylesheets are not yet loaded this may cause a flash of unstyled content. modernizr-2.6.2-respond-1.1.0.min.js:4:3946

downloadable font: bad search range (font-family: "TR Century Gothic" style:normal weight:400 stretch:100 src index:0) source: https://gobojangojss.co.bw/admin/bootstrap/css/TR%20Century%20Gothic.ttf

downloadable font: bad range shift (font-family: "TR Century Gothic" style:normal weight:400 stretch:100 src index:0) source: https://gobojangojss.co.bw/admin/bootstrap/css/TR%20Century%20Gothic.ttf

downloadable font: cmap: bad id_range_offset (font-family: "TR Century Gothic" style:normal weight:400 stretch:100 src index:0) source: https://gobojangojss.co.bw/admin/bootstrap/css/TR%20Century%20Gothic.ttf

Source map error: Error: request failed with status 404
Resource URL: https://gobojangojss.co.bw/admin/vendors/jquery-1.9.1.min.js
Source Map URL: jquery.min.map

标签: phplocalhostweb-hosting

解决方案


晚安,艾斯。
请检查您是否将 2 个文件上传到服务器:

  • 头文件.php
  • 脚本.php

另一种解决方案是打开 Chrome 控制台。按 F12
在 NAME 列中,您将看到与 Ajax 查询一起使用的 PHP 文件。 在此处输入图像描述

单击此 php 文件并查看从服务器返回给您的 POST 参数。
在此处输入图像描述

更新

此字符串告诉我们您的代码缺少 jquery。

Resource URL: https://gobojangojss.co.bw/admin/vendors/jquery-1.9.1.min.js

你能把它添加到函数,php文件中吗

wp_enqueue_script('jquery');

推荐阅读