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
Php Can';t通过$.ajax和child使用上层jquery脚本_Php_Jquery_Jquery Mobile - Fatal编程技术网

Php Can';t通过$.ajax和child使用上层jquery脚本

Php Can';t通过$.ajax和child使用上层jquery脚本,php,jquery,jquery-mobile,Php,Jquery,Jquery Mobile,最好的 我喜欢创建一个移动web应用程序,也喜欢使用jquery的$.ajax。 但是我认为“jquery.mobile-1.4.2.min.js”不能正常工作。因为当我编写jquery.mobile必须修改的代码时,它是有效的[请参见

最好的

我喜欢创建一个移动web应用程序,也喜欢使用jquery的$.ajax。 但是我认为“jquery.mobile-1.4.2.min.js”不能正常工作。因为当我编写jquery.mobile必须修改的代码时,它是有效的[请参见
------------index.php----------------

<head>
<link href="./css/myStyle.css" rel="stylesheet" type="text/css" />
<link href="./jQuery/jquery.mobile-1.4.2.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="./jQuery/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="./jQuery/jquery.mobile-1.4.2.min.js"></script>

<!-- this scripts containts testInAddedScriptFuncties() -->
<script type="text/javascript" src="jQuery/functies.js"></script>

<script type="text/javascript">

  function test() {
    alert('ok');
  }

  $(document).ready(function() {
  function load_page (source,page,par1,par2) {
        $.ajax({   
          beforeSend: function () {
                startVibrate(100);   
          },
          success: function () {

            $("#" + source).load("content/" + page, { "var": [par1,par2]})

          },
          complete: function() {

          }
        });
      }

  load_page("content","home.php");
});
</head>
<body>
<div id="content"></div> 

<form name="input" method="post">
   <input name="search-works" id="search-works" value="" placeholder="Zoek ..." type="search">
</form>

</body>
<script type="text/javascript">
    $(document).ready(function() {
       test(); <------ this works
       testInAddedScriptFuncties(); <----this works also 
       })
</script>

<!-- this doesn't work, it is visible but doesn't get modified by the js mobile-->
<form name="input" action="JavaScript:search()" method="post">
    <input name="search-doesnt" id="search-doesnt" value="" placeholder="Zoek ..." type="search">
</form>

功能测试(){
警报(“正常”);
}
$(文档).ready(函数(){
函数加载页面(源代码,页面,par1,par2){
$.ajax({
beforeSend:函数(){
startVibrate(100);
},
成功:函数(){
$(“#”+source).load(“content/”+page,{“var”:[par1,par2]})
},
完成:函数(){
}
});
}
加载页面(“content”,“home.php”);
});
------第二页home.php------------

<head>
<link href="./css/myStyle.css" rel="stylesheet" type="text/css" />
<link href="./jQuery/jquery.mobile-1.4.2.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="./jQuery/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="./jQuery/jquery.mobile-1.4.2.min.js"></script>

<!-- this scripts containts testInAddedScriptFuncties() -->
<script type="text/javascript" src="jQuery/functies.js"></script>

<script type="text/javascript">

  function test() {
    alert('ok');
  }

  $(document).ready(function() {
  function load_page (source,page,par1,par2) {
        $.ajax({   
          beforeSend: function () {
                startVibrate(100);   
          },
          success: function () {

            $("#" + source).load("content/" + page, { "var": [par1,par2]})

          },
          complete: function() {

          }
        });
      }

  load_page("content","home.php");
});
</head>
<body>
<div id="content"></div> 

<form name="input" method="post">
   <input name="search-works" id="search-works" value="" placeholder="Zoek ..." type="search">
</form>

</body>
<script type="text/javascript">
    $(document).ready(function() {
       test(); <------ this works
       testInAddedScriptFuncties(); <----this works also 
       })
</script>

<!-- this doesn't work, it is visible but doesn't get modified by the js mobile-->
<form name="input" action="JavaScript:search()" method="post">
    <input name="search-doesnt" id="search-doesnt" value="" placeholder="Zoek ..." type="search">
</form>

$(文档).ready(函数(){
test();

Load在加载的页面上运行任何js,然后将其作为简单html字符串返回

  • 必须在加载页面上包含jquery mobile并在那里运行,然后才能通过
    load
    返回

  • 将内容添加到DOM后,对从主页中返回的表单运行任何修改

  • 也许有必要考虑一下您在这里试图实现的目标,您的问题并不清楚,但如果我们讨论的是只获取表单元素
    load
    ,那就太过分了



    原始答案

    不要认为这与在home.php上加载jquery有关。你的javascript是错误的

  • 您在没有url的情况下调用$.ajax,这意味着它将尝试调用当前页面

  • 在成功回调中,然后尝试执行另一个ajax请求

  • 但是ajax调用从未运行,因为它被定义为
    load\u page\u pub
    ,而您正在调用
    load\u page

  • 如果它确实运行了,您可能会遇到问题,因为它需要四个参数,而您已经用两个参数调用了它

  • 暂时忽略这些额外参数:

    $(document).ready(function(){
        function load_page_pub (source,page) {
    
            //don't know what this does?
            startVibrate(100);
    
            $("#"+source).load(
                "content/"+page,
                {
                    //can add options here but should check they are defined first!
                },
                function(text, textStatus, XMLHttpRequest){
                    //do something here if need be.
                }
            )
        }
    
        load_page_pub("content","home.php");
    });
    

    我必须编写一个mobilejquery需要的触发器函数

    function(){
            $("#id").trigger('create');
    
    因此,完整的解决方案是:

    $("#" + source).load("content/" + page,{ "var": [par1,par2]},function(){
            $("#" + source).trigger('create');
            }); 
    

    你的ajax是否有url和类型等。我已将“load_page_sup”更改为“load_page”(我有多个函数,但使用了错误的函数,但现在它是正确的)load_page(“content”,“home.php”)应该启动所有内容。表单是可见的,但不由js scriptin home.php处理,将js代码放在page div中。我已更改了“load_page_pub”.StackOverflows上的错误也不起作用-但是为什么其他脚本和函数成功了?啊,那么你正试图使用jquery在home.php上修改你的表单?很抱歉,我没有从问题中得到答案。Load在加载的页面上运行任何js,然后将其作为简单的html字符串返回。请查看我编辑的答案。