0

I am trying to load my controllerMostrarMayorContenido in to an area(div ) on my page(index) and I can load pure text all, I read that It is using .html, It just retrieving the contents of my controller and paste it in index.php, I already do it in mootools but I dont find a way in jquery, It does not work

the problem is with this line document.getElementById('divrespuesta2').innerHTML= texto;

in moootools It works

  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();
}

in jQuery no

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');
            }
        });

}

2 Answers 2

3

A couple of problems in your jquery code:

  • It should be $('#divrespuesta2').html(texto); since you want the value of texto and not texto as text
  • You need to pass texto to your success callback function, it should look like this: success: function(texto) { ... }
Sign up to request clarification or add additional context in comments.

1 Comment

another comments aboout .html??
0

The first argument in the ajax success handler is the response returned by the server resource. Try this

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);
            }
        });

}

1 Comment

thanks for answering I understand better the error all othe question another comments aboout .html?? I already trying to understand

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.