Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.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
第二次使用JQuery ajax获取local.HTML内容时,index.HTML的js无效_Jquery_Html_Ajax_Cordova - Fatal编程技术网

第二次使用JQuery ajax获取local.HTML内容时,index.HTML的js无效

第二次使用JQuery ajax获取local.HTML内容时,index.HTML的js无效,jquery,html,ajax,cordova,Jquery,Html,Ajax,Cordova,我很抱歉我的英语不好 现在我在做phonegap开发。 我想使用JQuery ajax获取local.HTML内容,并通过index.HTML中的id=“next page”将该内容插入div。我第一次点击btn时一切正常。但是当 第二次单击btn时,它可以跳转到页面,但缺少查询listview、li的类。我认为是jquery.js和jquery-mobile.js无效。 有人能帮我吗? 谢谢 这是我的index.html <!DOCTYPE html> <html> &

我很抱歉我的英语不好

现在我在做phonegap开发。 我想使用JQuery ajax获取local.HTML内容,并通过index.HTML中的id=“next page”将该内容插入div。我第一次点击btn时一切正常。但是当
第二次单击btn时,它可以跳转到页面,但缺少查询listview、li的类。我认为是jquery.js和jquery-mobile.js无效。 有人能帮我吗? 谢谢

这是我的index.html

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<title>demo</title>
<link rel="stylesheet"  href="jquery.mobile-1.0.css" />
<link rel="stylesheet" href="css/chui.css"/>
<link rel="stylesheet" href="index.css"/>
<script type="text/javascript" charset="utf-8" src="js/phonegap-1.3.0.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.mobile-1.0.js"></script>
<script type="text/javascript" src="js/iscroll.js"></script>
<script type="text/javascript" src="index.js"></script>

</head>
<body>
<!--home page:schedule-->
<div data-role="page" id="schedule">
    <div data-role="header" data-theme="b"></div>

<div id="wrapper1">
    <div id="scroller">
        <div data-role="content">
            <ul data-role="listview" data-inset="true" data-theme="d" class="ulspan">
                <li><a id="first-btn">Carrier<span></span></a></li>
            </ul> 
         </div>
     </div>
</div>
</div>


<div data-role="page" id="next-page">

</div>

我不确定我是否理解正确。您是说第二次单击按钮时,AJAX调用的内容会显示在页面上,但格式不正确吗

如果是这样的话,可能是因为你需要打电话

$('#carrier').listview('refresh');
在动态注入新的listview之后


话虽如此,您的方法还存在其他问题,但上面的内容应该可以解决您当前的问题。

我还没有使用jQuery mobile,但我认为您不必通过ajax和$.mobile.changePage加载页面。谢谢您的回复。您能告诉我您是如何做到的吗?谢谢Steve!我尝试了你的建议,但没有效果。当我第二次点击btn时,它可以跳转到页面,但是列表视图的css无效,我发现brower调试工具(class=“ui listview”…..)中缺少标签的类。所以我认为JQuery.js或JQuery-mobile.js无效。
$.ajax({
           url:"carrier.html",
           async:true,
           type:'Get',
           dataType:'html',
           timeout:5000,
           error:function(data){showAlert('Error loading data')},
           success:function(data){
           console.log(data);
           $("#next-page").html(data);
           $.mobile.changePage($("#next-page"),{transition:"slide"});
   })
$('#carrier').listview('refresh');