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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.