Jump to content

innerHTML


corillo181

Recommended Posts

i used to use innerHTML to include forms in my website with AJAX but now this is deprecated.

i like to keep my website 100% W3C standard.

 

how can i chage my code to insert forms?

<script>
function getForm(id,file){

  var request = null;
    if(window.xmlHttpRequest){
      request = new xmlHttpRequest();
    }else if(window.ActiveXObject){
//request for IE
      request = new ActiveXObject('Microsoft.XMLHTTP');
    }

  if(request){
   request.open("GET",file);
    request.onreadystatechange = function(){
       if(request.readyState == 4){
          document.getElementById(id).innerHTML = request.responseText;
         }
     }
  request.send(null);
}
}
</script>

Link to comment
https://forums.phpfreaks.com/topic/75093-innerhtml/
Share on other sites

in order to recieve a form from ajax and then add it to your page without innerHTML'ing it, you would have to write code to:

 

1) parse the entire form recieved, parsing out not only tags like INPUT and SELECT, but also any attributes that are within those tags like 'value=' or 'style=' or OPTION or 'class='.

2) automate the process of taking all those tags and attributes and generating w3c 'standards' code that will create the necessary nodes and subnodes.

3) make the code above cross browser compatable because the different browsers implement parts of the 'standards' different#!@?

 

--if you can do all that, then must be ready to design the next space shuttle too, and I would dare say way ahead of anybody on this board! No really, if you are going to be adding a couple of fields to an already existing form, then go ahead and w3c standards it.  But if you are recieving a whole form from ajax, just innerHTML it, that's what prototype.js does!

 

Link to comment
https://forums.phpfreaks.com/topic/75093-innerhtml/#findComment-382334
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.