Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/403.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
Javascript 重新加载部分页面时的AJAX请求_Javascript_Php_Jquery_Html_Ajax - Fatal编程技术网

Javascript 重新加载部分页面时的AJAX请求

Javascript 重新加载部分页面时的AJAX请求,javascript,php,jquery,html,ajax,Javascript,Php,Jquery,Html,Ajax,我是新注册的,但多年来一直是个安静的读者。 到目前为止,我已经通过搜索堆栈溢出找到了所有问题的答案,但现在我不得不问 我是AJAX新手,我正在为AJAX请求构建一个测试ap。 我遵循了本页中的示例。 关于我的测试ap的信息: 这一切都是关于编写向导的。 这段代码来自我的“wizzard.php” php通过JQUERY在一个文件中加载“wizzard.php” 具有某些id的内容div。 因此,框架等的所有内容都包含在index.php中。 目前为止 该向导可以正常工作并在浏览器中正确显示 现

我是新注册的,但多年来一直是个安静的读者。 到目前为止,我已经通过搜索堆栈溢出找到了所有问题的答案,但现在我不得不问

我是AJAX新手,我正在为AJAX请求构建一个测试ap。 我遵循了本页中的示例。

关于我的测试ap的信息: 这一切都是关于编写向导的。 这段代码来自我的“wizzard.php”

php通过JQUERY在一个文件中加载“wizzard.php” 具有某些id的内容div。 因此,框架等的所有内容都包含在index.php中。 目前为止 该向导可以正常工作并在浏览器中正确显示

现在的问题是: 向导本身有一个按钮“下一步”。如果你点击它,你会看到 向导中的另一个“页面”(步骤)。html如下所示:

    <div id="wiz1step3">

      <h4 class="widgettitle">Step 3: Overview</h4>
      <div class="par terms" style="padding: 0 20px;">
        <p>Hier werden zusammenfassend.</p>
        <p>Alle Informationen gesammelt die das Hinzufügen betreffen</p>
        <div id="DeviceTypeIdHint"><b>DeviceTypeID will be listed here...</b>
        </div>

        <p>
          <input type="checkbox" />I agree with the terms and agreement...</p>
      </div>
    jQuery('.buttonNext').click(function(e) {
          //Hier kommt der AJAX Aufruf für das Besorgen der ID des        ausgewähltenDevices

          e.preventDefault();
          var deviceTypeModel = jQuery('#selection option:selected').text();

          if (deviceTypeModel == "") {
            document.getElementById("DeviceTypeIdHint").innerHTML = "Es wurde keine    ID Zugeordnet";
          } else {
            if (window.XMLHttpRequest) {
              //code for IE7+, Firefix, Chrome, Opera, Safari                 
              xmlhttp = new XMLHttpRequest();
            } else {
              // code for IE6, IE5
              xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }

            xmlhttp.onreadystatechange = function() {
              alert(xmlhttp.readyState)
              if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("DeviceTypeIdHint").innerHTML = xmlhttp.responseText;
              }
            }

            xmlhttp.open("GET", "getDeviceTypeIdFromDeviceTypeModel.php?q=" + deviceTypeModel, true);
            xmlhttp.send;
          }
<?php

    /* 
     * nimmt AJAX Anfragen entgegen und führt sie aus
     */
    include_once '\includes\DataAccess.php';

    $DataAccess = new DataAccess();
    $DeviceTypeNameFromRequest = $_GET['q'];
    $AJAX_DeviceTypeId = $DataAccess ->GetDeviceTypeIdForDeviceTypeModel($DeviceTypeNameFromRequest);
    echo $AJAX_DeviceTypeId;
与index.php和wizzard.php的方向相同 是“GetDeviceTypedFromDeviceTypeModel.php”。位于。 这是应该执行AJAX巫术的文件

看起来是这样的:

    <div id="wiz1step3">

      <h4 class="widgettitle">Step 3: Overview</h4>
      <div class="par terms" style="padding: 0 20px;">
        <p>Hier werden zusammenfassend.</p>
        <p>Alle Informationen gesammelt die das Hinzufügen betreffen</p>
        <div id="DeviceTypeIdHint"><b>DeviceTypeID will be listed here...</b>
        </div>

        <p>
          <input type="checkbox" />I agree with the terms and agreement...</p>
      </div>
    jQuery('.buttonNext').click(function(e) {
          //Hier kommt der AJAX Aufruf für das Besorgen der ID des        ausgewähltenDevices

          e.preventDefault();
          var deviceTypeModel = jQuery('#selection option:selected').text();

          if (deviceTypeModel == "") {
            document.getElementById("DeviceTypeIdHint").innerHTML = "Es wurde keine    ID Zugeordnet";
          } else {
            if (window.XMLHttpRequest) {
              //code for IE7+, Firefix, Chrome, Opera, Safari                 
              xmlhttp = new XMLHttpRequest();
            } else {
              // code for IE6, IE5
              xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }

            xmlhttp.onreadystatechange = function() {
              alert(xmlhttp.readyState)
              if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("DeviceTypeIdHint").innerHTML = xmlhttp.responseText;
              }
            }

            xmlhttp.open("GET", "getDeviceTypeIdFromDeviceTypeModel.php?q=" + deviceTypeModel, true);
            xmlhttp.send;
          }
<?php

    /* 
     * nimmt AJAX Anfragen entgegen und führt sie aus
     */
    include_once '\includes\DataAccess.php';

    $DataAccess = new DataAccess();
    $DeviceTypeNameFromRequest = $_GET['q'];
    $AJAX_DeviceTypeId = $DataAccess ->GetDeviceTypeIdForDeviceTypeModel($DeviceTypeNameFromRequest);
    echo $AJAX_DeviceTypeId;
问题是readyState始终为1。 我的xmlhttp.responseText始终为空

我不明白为什么这个请求不起作用。 Div提示没有改变

请注意,对于这种糟糕的格式设置,我深表歉意
这是我的第一篇帖子。。。这个语法修正让我很恼火,我正在努力使用“代码剪切工具”XD

问题是您使用的是
xmlhttp.send
而不是
xmlhttp.send()

编辑:整个JQUERY内容都在JQUERY(文档)中。准备好了(函数(){}尝试xmlhttp.send(),而不是xmlhttp.send这是错误!:)谢谢!现在一切正常。为了一个语法错误,我的头撞了好几个小时>\u不客气。请你接受我的回答好吗?谢谢