Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php jquerymobile使用ajaxpost丢失css_Php_Jquery_Html_Css_Jquery Mobile - Fatal编程技术网

Php jquerymobile使用ajaxpost丢失css

Php jquerymobile使用ajaxpost丢失css,php,jquery,html,css,jquery-mobile,Php,Jquery,Html,Css,Jquery Mobile,我正在用jQuery mobile创建一个移动应用程序,我有一个小问题。我想创建一个列表,其中包含从ajax帖子中获得的数据库中的一些内容 标记如下所示: <div data-role="page"> <div data-role="header"> <h1>Facturen</h1> </div><!-- /header --> <div data-role="content"> <

我正在用jQuery mobile创建一个移动应用程序,我有一个小问题。我想创建一个列表,其中包含从ajax帖子中获得的数据库中的一些内容

标记如下所示:

<div data-role="page">
<div data-role="header">
    <h1>Facturen</h1>
</div><!-- /header -->

<div data-role="content">   
    <ul data-role="listview" data-inset="true" id="Invoices">
        <div id="invoiceList"></div>
    </ul>
</div><!-- /content -->

<div data-role="footer">
    <h4>Page Footer</h4>
</div><!-- /footer -->
好吧,我把查询结果放在
  • 之间,但在某种程度上,列表的css不起作用

    如果我尝试一下,效果很好:

    <ul data-role="listview" data-inset="true" id="Invoices">
            <li>test</li>
            <li>test</li>
            <li>test</li>
            <li>test</li>
        </ul>
    
    • 试验
    • 试验
    • 试验
    • 试验
    有人知道怎么解决这个问题吗


    提前谢谢

    尝试将您的
    id
    作为
    class
    invoiceList
    添加到
    ul
    元素中,因为您在
    div
    元素中添加
    li
    元素,格式设置将不起作用:

    <ul data-role="listview" data-inset="true" id="Invoices" class="invoiceList">
    
    </ul>
    
    <script>
    $.ajax({
        type: "POST",
        url: "invoices/index.php",
        data: '',
        complete: function(data)
        {
            $('.invoiceList').html(data.responseText);
        }
    });
    </script>
    
    $.ajax({ 类型:“POST”, url:“invoices/index.php”, 数据:“”, 完成:功能(数据) { $('.invoiceList').html(data.responseText); } });
    在jQuery Mobile中,每当您更新元素时,通常会有一个后续步骤,在此步骤中您会触发一个操作。例如,当您将新事物添加到未排序的列表中时,您需要调用

    $('#invoiceList').listview('refresh');
    
    complete:
    回调中将这些元素添加到UL中后,将立即执行此操作


    如果这不能产生你想要的行为,你还可以尝试其他各种方法。例如,您可能需要执行该操作,而不是使用
    .html()
    。在这种情况下,我更经常看到这种用法。

    我已经尝试过了,但不幸的是,它不起作用。也许这是jquery手机的问题……太好了,@LeonvanderVeen;很高兴你的列表现在得到了css
    $('#invoiceList').listview('refresh');