JS HTTP XML Requests

free web hosting
Open Discussion > Have your say > General Talk

JS HTTP XML Requests

God
Alright. This script, when complete, will use javascript to request the contents of a page on any server, then update the current page, placing the new content into a div somewhere on the page. With a little modification, you can use it for your sites, provided that your site is not very complicated. If you want me to help you implement this on your site, or would like me to do it, PM me.

You can view a demo of the technology at http://codefx.titaniumhosting.com/jstest/index.php I spent very little time on the graphics and content, so it won't look very pretty, but you can see the script in action. Right now it's down, but it should be back up soon. I believe it should work, but I'll have to verify that once it goes back.

scripts.js:
CODE
var xmlhttp=false;

/*@cc_on @*/

/*@if (@_jscript_version >= 5)

// JScript gives us Conditional compilation, we can cope with old IE versions.

// and security blocked creation of the objects.

try {

 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

} catch (e) {

 try {

  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

 } catch (E) {

  xmlhttp = false;

 }

}

@end @*/

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {

xmlhttp = new XMLHttpRequest();

}



function loadpage(fragment_url, element_id) {

var element = document.getElementById(element_id);

element.innerHTML = '<em>Loading ...</em>';

xmlhttp.open("GET", fragment_url);

xmlhttp.onreadystatechange = function() {

 if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

  element.innerHTML = xmlhttp.responseText;

 }

    }

xmlhttp.send(null);

}



That was the only important part. The rest is site-specific.

To implement this, you'll have to make two things different from a normal site.
1. You'll have to have a container of some sort with a unique id attirbute. This will be where new page are loaded into, so make it fairly big. A table cell will work, but the msot effective element for this is a div. You can set its scrolling method to auto using CSS, which will allow the content to overflow without causing problems for your layout.
2. For EVERY SINGLE LINK that you want to load into the element, you'll have to change its format:
The normal style for a link is as follows:
CODE
<a href="somepage.html">Click</a>


The correct suntax for the new style is: (This applies to the example)
CODE
<a href="javascript: loadpage('somepage.html','div_id_here');">Click</a>



Notes:
1. You need to replace the div_id_here part of the link to the id you have given your container.
2. For this script to be compatable with Mozilla/Firefox/Netscape, EVERY URL must be a relative one!!! This is because these browsers are mroe secure and will not allow you to perform this action to get a page from a difference domain. This includes simply adding a "www." where there is not one in the path. If you truly want to link to another page, you'll have to get your version of the script signed. Click here for more information on that.
3. I have not yet figured out a way to pass form data along through the request. This may or may not be possible. I'll get back to you on that.


Any other questions you can psot in here. Again, if you want help implementing it, PM me.


If you use this, I would greeatly appreciate it if you would link back to my site, http://codefx.titaniumhosting.com/. Thanks. My button is in one of the blocks.

 

 

 


Reply

welbis
I dont understand...

does this script make it show 'loading' while the page loads... or is that something else?

Reply

God
No, go see the demo! biggrin.gif

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. javascript httpxml - 305.37 hr back. (1)
Similar Topics

Keywords : js http xml requests

  1. http://www.e-sword.net (Bibles, commentaries, others) - (3)
    For those that never heard of e-sword, it is a Bible software in which you can have plenty of
    Bibles, commentaries, dictionaries, Christian living books, maps, concordances and others in one
    package. It is free! http://www.e-sword.net ...
  2. Http://www.text-image.com - One of the coolest thing ever! (0)
  3. Timegamer Company's Website - http://www.timegamercompany.piczo.com (1)
    Please visit my company's website below. I have more info about my site on there shown there
    htpp://www.timegamercompany.piczo.com...
  4. Does This Link Work For You? - http://68.203.246.27:8080/index.html (6)
    does this link work for you? i need to take a test online but the link doest works =-\
    http://68.203.246.27:8080/index.html ...
  5. Chat Room? Visit: http://www.lhcw.net/FNH - (42)
    Would you like a Java Based Chat Room?...
  6. http://www.cheapdesign.co.uk/pulseradio/index.html - (7)
    i have not yet completed this website, because i dont currently have webhosting. but my mate has let
    me upload this website temp so that you can see a sneak preview
    http://www.cheapdesign.co.uk/pulseradio/index.html ...
  7. http://marionie.tripod.com - (9)
    I'm a terrible newbie so I stumbled through FrontPage to create this. My original one used an FP
    theme--but the elements wouldn't go online with the rest of the page when I tried to publish! So, I
    simplified everything based on a design a very kind person from another forum suggested. I tried
    to make it look professional. I wish I could put those shadowed button thingies on (or whatever you
    call them LOL!). I dunno, what do you think? http://marionie.tripod.com Thanks!...
  8. http://www.vaio-hosting.com/cpanel isnt working - (5)
    http://www.vaio-hosting.com/cpanel isnt working ive got: CODE Internal Server Error The
    server encountered an internal error or misconfiguration and was unable to complete your request.
    Please contact the server administrator, webmaster@vaio-hosting.com and inform them of the time the
    error occurred, and anything you might have done that may have caused the error. More information
    about this error may be available in the server error log. Additionally, a 404 Not Found error
    was encountered while trying to use an ErrorDocument to handle the request. Ap...
  9. http://xof7.tk - (9)
    Since i am still waiting for the admins to get to my site(no pressure). Take a look at my site.
    http://Xof7.tk Let me know what you think....
  10. My Space band requests - (0)
    I think my space is a great way to get your band heard, I don't think they are annoying....
  11. Http://dukenuking.cjb.net - (15)
    Lo here is my homepage still working on it. What do you think about design?
    Http://dukenuking.cjb.net ...
  12. http://www.then00btrainers.com/ - (5)
    http://www.then00btrainers.com/ ...
  13. False Requests for Information - Watch out for posers (18)
    The single biggest threat in security is the human element. Methods such as social engineering are
    one of the easiest ways for an intruder to gain access to information they shouldn't know. It
    is important that everyone watch out for false claims of authority, and requests for sensitive
    information - especially passwords. If you receive a private message or email from someone claiming
    to have permission from an administrator, or that they are in a position to rightfully have access
    to such information, then it is strongly recommended that you check that what they ar...
  14. www.asyiklin.tk OR http://www.asyiklin.freeweb-hosting.com - (11)
    this is my first site. /tongue.gif' border='0' style='vertical-align:middle' alt='tongue.gif' />
    www.asyiklin.tk ...
  15. Order of the requests is wrong, I think... - (24)
    The order of the posts in the request for free host is the tipical: last post date To the
    admin(s): If you go to the admin panel, then forum admin, then edit that forum, you can set the
    order the forum should be displayed. I think you should select topic date, and not last post date
    (as predefined). I saying this, because I was the first guy to request and I'm still waiting...
    please see this topic ....
  16. Online ATOM reader need help: Basic HTTP Auth - (0)
    I'm using migpierss 0.61 so I can get the atom feeds, but I need it to read atom feeds protected via
    basic http authroization. Any help? It's for a gmail tab for tabmgr /biggrin.gif' border='0'
    style='vertical-align:middle' alt='biggrin.gif' /> I read in the magpie blog that this url
    should work: CODE https://user:pass*gmail.google.com/gmail/feed/atom But it
    doesn't....



Looking for js, http, xml, requests

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for js, http, xml, requests

*MORE FROM TRAP17.COM*
advertisement



JS HTTP XML Requests



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE