在jQuery问题中使用.html?

在jQuery问题中使用.html?,jquery,Jquery,我正在尝试将我的ControllerMosterArmayorContenido加载到我页面(索引)上的一个区域(div),我可以加载纯文本,我读到它正在使用.html,它只是检索我控制器的内容并将其粘贴到index.php中,我已经在mootools中这样做了,但我在jquery中找不到方法,它不起作用 问题出在这条线路上 document.getElementById('divrespuesta2')。innerHTML=texto 在moootools中它起作用 var prueboR

我正在尝试将我的ControllerMosterArmayorContenido加载到我页面(索引)上的一个区域(div),我可以加载纯文本,我读到它正在使用.html,它只是检索我控制器的内容并将其粘贴到index.php中,我已经在mootools中这样做了,但我在jquery中找不到方法,它不起作用

问题出在这条线路上 document.getElementById('divrespuesta2')。innerHTML=texto

在moootools中它起作用

  var prueboRequest = new Request({
   method: 'POST',
//   data: 'id_tema='+id_tema,
   url: '../controller/controllerTema/controllerMostrarMayorContenido.php',
   onRequest: function() {}, 
   onSuccess: function(texto, xmlrespuesta){
   document.getElementById('divrespuesta2').innerHTML= texto; this line

   },
   onFailure: function(){alert('Fallo');}
}).send();
}
在jqueryno中

function limpiarDiv(id_tema){
     document.getElementById("divrespuesta2").innerHTML="";
     document.getElementById("divrespuesta3").innerHTML="";

        $.ajax({

            type: "POST",
            url: '../controller/controllerTema/controllerMostrarMayorContenido.php',
            beforeSend:function(){alert('ejecutandose');},
            success: function(){
                //document.getElementById('divrespuesta2').innerHTML= texto; 
                $('#divrespuesta2').html('texto');
            }
        });

}

jquery代码中有几个问题:

  • 它应该是
    $('#divrespuesta2').html(texto)因为您想要的是texto的值,而不是texto作为文本
  • 您需要将
    texto
    传递给success回调函数,它应该是这样的:
    success:function(texto){…}

jquery代码中有几个问题:

  • 它应该是
    $('#divrespuesta2').html(texto)因为您想要的是texto的值,而不是texto作为文本
  • 您需要将
    texto
    传递给success回调函数,它应该是这样的:
    success:function(texto){…}

    • ajax成功处理程序中的第一个参数是服务器资源返回的响应。试试这个

      function limpiarDiv(id_tema){
           document.getElementById("divrespuesta2").innerHTML="";
           document.getElementById("divrespuesta3").innerHTML="";
      
              $.ajax({
      
                  type: "POST",
                  url: '../controller/controllerTema/controllerMostrarMayorContenido.php',
                  beforeSend:function(){alert('ejecutandose');},
                  success: function(response){
                      //document.getElementById('divrespuesta2').innerHTML= texto; 
                      $('#divrespuesta2').html(response);
                  }
              });
      
      }
      

      ajax
      success处理程序中的第一个参数是服务器资源返回的响应。试试这个

      function limpiarDiv(id_tema){
           document.getElementById("divrespuesta2").innerHTML="";
           document.getElementById("divrespuesta3").innerHTML="";
      
              $.ajax({
      
                  type: "POST",
                  url: '../controller/controllerTema/controllerMostrarMayorContenido.php',
                  beforeSend:function(){alert('ejecutandose');},
                  success: function(response){
                      //document.getElementById('divrespuesta2').innerHTML= texto; 
                      $('#divrespuesta2').html(response);
                  }
              });
      
      }
      

      谢谢你的回答,我能更好地理解错误所有其他问题另一个评论about.html??我已经试着理解了谢谢你的回答我更好地理解了错误所有其他的问题另一个评论about.html??我已经试着理解其他的注释about.html??另一个注释about.html??