INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

putting an html file inside div tags

putting an html file inside div tags

(OP)
Trying to put an html file in div tags. It works if I use method get but want post. It also works if the extension of the filename "fn" that goes to f() is cfm instead of html.
What am I doing wrong?

This is the dtry.html that sets up the screen and tries to put dtry1.html (further down) into the div area "content".

CODE -->

<html>
   <head>
      <title>
      </title>
      <script type="text/javascript">
         function f(fn,dn)
         {
            var req=false;
            if (window.XMLHttpRequest)
               req=new XMLHttpRequest()
            else
               if (window.ActiveXObject)
                  req=new ActiveXObject("Microsoft.XMLHTTP");
            if (req)
            {
               req.open("POST",fn,true);
               req.setRequestHeader("Content-type","application/x-www-form-urlencoded");
               req.onreadystatechange=function()
                                      {
                                         if (req.readyState==4 && req.status==200)
                                         {
                                            document.getElementById(dn).innerHTML=req.responseText;
                                            delete req;
                                            req=null
                                         }
                                      };
               req.send()
            }
            else
            {
               alert('No req.');
               return false
            };
         }
         function aa()
         {
            alert('*')
         }
      </script>
      /*style sheet part goes here*/
   </head>
   <body>
      <div id="outer">
         <div id="header1">
         </div>
         <div id="header2">
         </div>
         <div id="sider">
            <a href="#" id="a2" onclick="f('dtry1.html','content');">
               click
            </a>
         </div>
         <div id="content">
            Content
         </div>
         <div id="footer">
            Footer
         </div>
      </div>
   </body>
</html> 
Below is dtry1.html I want inside the div "content" is here.

CODE -->

<html>
   <head>
      <title>
      </title>
   </head>
   <body>
      <a href="#" id="aa" onclick="aa();"> /*works if aa() in file with f()*/
         click
      </a>
      <form>
         <input name="bb" type="submit" value="click" onclick="f('dtry2.html','content');">
      </form>
   </body>
</html> 

RE: putting an html file inside div tags

Quote:

is cfm instead of html.

Maybe because it is coming from a ColdFusion server??


Is the server set to deliver content using POST?

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: putting an html file inside div tags

(OP)
I think it's set to deliver content with POST since on that server I use method POST with ColdFusion and the script above, f(), with img tags around req.responseText, can display a picture with POST.

RE: putting an html file inside div tags

(OP)
I think it's set to work with POST since that's what I use with ColdFusion and since in the script above, f(), when req.responseText's value is the name of an image file and content's innerHTML is set to '<img src='+req.responseText+'>', the picture displays. In f(), the html file will show when GET is used instead of POST.

RE: putting an html file inside div tags

Is there an html file with that name in the same path as the base file that's trying to load it?

Usually Ajax is not used to load static html pages, and your server may be preventing this, but that would be a server config.

Have you tried alerting what if anything the ajax call is returning?

CODE

if (req.readyState==4 && req.status==200)
                                         {
alert($req.responseText);
                                            document.getElementById(dn).innerHTML=req.responseText;
                                            delete req;
                                            req=null
                                         } 


Also have you checked for any errors in the JS console? Most browsers have one of these.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

RE: putting an html file inside div tags

(OP)
Yes, there is a file with that name.
When fn is html, responseText is an error message "the HTTP verb used to access this page is not allowed" and status=405.
Sorry didn't check this earlier.

RE: putting an html file inside div tags

Seems POSTING to a static HTML page is not allowed in your setup.

What happens if you change the method to GET instead? Since its HTML, it won't matter as you aren't really passing any values to it to be processed. so you just want to get the page rather than post values to it.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

RE: putting an html file inside div tags

(OP)
It works with GET. Later I want to send values. Maybe best to use cfm for that?

RE: putting an html file inside div tags

Yes. If you want to send values, then a static HTML page will do nothing with them. You would need a server side script that can access the values and do something with them. HTML cannot do that. So when you deicde to send values you would need a CFM script that can process the posted values.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

RE: putting an html file inside div tags

You can use GET on a static HTML page and use JS to read the QS values. Though if you load the page via AJAX this may not be possible. It also isn't a nice way to process GET parameters.

As Phil states POST will not work on a static HTML page.

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close