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.

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

报告相同问题?

悬赏问题

  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错