Php Jquery移动和.load函数

Php Jquery移动和.load函数,php,jquery,css,jquery-mobile,Php,Jquery,Css,Jquery Mobile,我正在尝试将我的网站转移到jquery mobile中,但在使用时遇到错误: $('#information').load('getRegister.php' , function() { $('#preloader').hide(); }); 调用此函数可将html代码动态加载到页面中,而无需刷新,但显示的代码与网站中已有的css代码不匹配。您可以在下面的屏幕截图中看到这一点: 我很困惑,为什么按钮和文本字段没有采用

我正在尝试将我的网站转移到jquery mobile中,但在使用时遇到错误:

$('#information').load('getRegister.php'  , function() {
                    $('#preloader').hide(); 
                });
调用此函数可将html代码动态加载到页面中,而无需刷新,但显示的代码与网站中已有的css代码不匹配。您可以在下面的屏幕截图中看到这一点:

我很困惑,为什么按钮和文本字段没有采用已经加载到页面中的表单的样式。.load调用的代码是以下php文件:

<?php
  require ('myConnectDB.inc.php');     

// echo registration form

echo "

<p class=\"center\"> &nbsp;</p>

<form name=\"input2\" action=\"\" onsubmit =  \" return register()\" method=\"post\"  data-ajax=\"false\">
                    <p class=\"center\"> User Name: 
                    <input type=\"text\" name=\"user\"  id=\"userRegister\" /></p>
                    <p class=\"center\"> &nbsp;</p>
                    <p class=\"center\"> Email: 
                    <input type=\"text\" name=\"user\"  id=\"emailRegister\" /></p>
                    <p class=\"center\"> &nbsp;</p>
                    <p class=\"center\"> Password: <input type=\"password\" name=\"password\" id=\"passwordRegister1\" /></p> 
                    <p class=\"center\"> &nbsp;</p>
                    <p class=\"center\"> Re-Type Password: <input type=\"password\" name=\"password\" id=\"passwordRegister2\" /></p> 
                    <p class=\"center\"> &nbsp;</p>
                    <p class=\"center\"> 
                    <input type=\"submit\"  class=\"  button blue\" name = \"login\" value=\"Register\" />
                    </p>
            </form>";   
?>

这可能是因为新html没有提供与原始表单相同的类属性,也没有提供原始样式表使用的任何嵌套div结构


查看原始文本字段的class属性并匹配这些字段。或者查看样式表以了解如何布局html。

您需要在新添加的内容上触发
create
事件

是否应通过客户端生成新标记或加载内容 AJAX并将其注入页面中,您可以触发create事件 处理中包含的所有插件的自动初始化 新的标记。这可以在任何元素(甚至页面)上触发 div本身),省去了手动初始化每个插件的任务 (见下文)

例如,如果加载了一块HTML标记(比如登录表单) 在中,通过Ajax触发create事件以自动转换 它包含的所有小部件(输入

和按钮(在本例中为)转换为增强版。代码 这种情况将是:

在你的情况下,你可能会想做如下的事情

$('#information').load('getRegister.php'  , function() {
        $('#preloader').hide(); 
        $('#information').trigger("create");
 });

非常感谢你的帮助。你回答得太快了,我还不能认为你的答案是对的。但三分钟后我会的!欢迎您,如果您还没有阅读,我建议您也阅读一下关于链接页面以及通过ajax加载页面和全文之间的区别。
$('#information').load('getRegister.php'  , function() {
        $('#preloader').hide(); 
        $('#information').trigger("create");
 });