doudou3716 2015-01-15 22:00 采纳率: 100%
浏览 54
已采纳

保存为php的JqueryMobile页面在通过xampp托管时无法正确显示

I have a php-file called loginscreen.php. For now it contains two JqueryMobile pages and a form on the first page to login. The login process is working just fine. The whole thing is hosted with xampp (Version: 5.6.3-0) on my Mac.

When I change the file extension of my loginscreen.php file to .html (so --> loginscreen.html) and open it in the htdocs folder in finder, the loginscreen page opens just fine in Safari in correct jquery mobile style after my custom theme, the login process works and gets me to my second page.

However, if I access the loginscreen.php in my browser with localhost/loginscreen.php the file renders wrongly. I get double buttons (usual html button within jQuery button). Double input fields (same as buttons). My second page is being displayed as well and when login in I get a page load error!

What's my problem here? Since it works when opening the file as an html via finder I suppose the problem is my xampp hosting. What could the problem be so that my files don't render correctly when hosted via xampp?

My code (The loginscreen.php file)(There's also a javascript and another php file being responsible for the login via ajax and php to access my database (also hosted with xampp) everything working properly when being opened via finder as html but not when accessed through browser as php)

<!doctype html>
<html><head>
<title>Prototyplogin</title>
<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- <meta name="viewport" content="initial-scale=1, maximum-scale=1"> -->
    
<link rel="stylesheet" href="themes/mensa1.min.css" />
<link rel="stylesheet" href="themes/jquery.mobile.icons.min.css" />
<link rel="stylesheet" href="jquery/jquery.mobile.structure-1.4.5.min.css" />
<link rel="stylesheet" type="text/css" href="loginscreen.css" />
    
<script type="text/javascript" src="jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="jquery.mobile-1.4.5.js"></script>
<script type="text/javascript" src="loginscreen.js"></script>
    
</head>
    
<body>

    <div data-role="page" data-theme="c" id="loginscreen">
    
            <div data-role="main" class="ui-content">
            <br />
                <div id="titel">
                    <p>Logo</p>
                </div>
            <br />
            <form action="test.php" method="post" id="loginformular">
                <label for="username">Benutzername:</label>
                <input type="text" name="username" id="username">
                <br/>
                <label for="password">Passwort:</label>
                <input type="password" name="password" id="password">
                <br/>
                <input type="button" value="Anmelden" id="submit" data-role="button">
            </form>
            <div id="notificationdiv"><h3 id="notification"></h3></div>
            </div>
    </div>
    
    <div data-role="page" id="firstpage">
    
        <div data-role="header">
        
        </div>
        <div data-role="main" class="ui-content">
            <h1>Secondpage</h1>
        </div>
        
        <div data-role="footer">
        
        </div>
    </div>
</body>
</html>

Searched the whole internet for this issue, would be awesome to receive some help! :-) Thanks for your help in advance! :-)

</div>
  • 写回答

1条回答 默认 最新

  • doujiu5464 2015-01-24 13:19
    关注

    I figured out the problem myself. The problem didn't have anything to do with my XAMPP installation. I figured out the two actual problems:

    1. My PHP file didn't have the header('Content-Type: text/html; charset=utf-8'); and there for I ran into errors and misbehavior of my code, because my index.php file was set to utf-8 with a meta tag, but without the header('Content-Type') my PHP code wasn't.

    2. My Jquery-Mobile CSS wasn't wrongly imported. I only imported the Jquery-Mobile-Strucutre.css after my theme instead of the normal Jquery-Mobile.css. This was responsible for the double renderings and wrong displays as well as for the wrong page display behavior, because some crucial page elements are missing when not importing the standard Jquery-Mobile.css.

    Hope this helps some other people running into these issues, took me quite a while to figure out the encoding issue with utf-8.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 VFP如何使用阿里TTS实现文字转语音?
  • ¥100 需要跳转番茄畅听app的adb命令
  • ¥50 寻找一位有逆向游戏盾sdk 应用程序经验的技术
  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题