corillo181 Posted October 28, 2007 Share Posted October 28, 2007 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> Quote Link to comment Share on other sites More sharing options...
micah1701 Posted October 29, 2007 Share Posted October 29, 2007 huh, i didn't know it was depreciated. thanks for the heads up. here's the first article I googled on it: http://www.bestcodingpractices.com/break_your_innerhtml_addiction-2719.html Quote Link to comment Share on other sites More sharing options...
corillo181 Posted October 31, 2007 Author Share Posted October 31, 2007 but the new metho doesn't show how i would put in normal html. its too much work just to get regular html in there. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted October 31, 2007 Author Share Posted October 31, 2007 ...................... Quote Link to comment Share on other sites More sharing options...
corillo181 Posted October 31, 2007 Author Share Posted October 31, 2007 .............. Quote Link to comment Share on other sites More sharing options...
fenway Posted October 31, 2007 Share Posted October 31, 2007 What is "normal html"? Quote Link to comment Share on other sites More sharing options...
mainewoods Posted October 31, 2007 Share Posted October 31, 2007 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.