SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How to get contents of 3rd party website into javascript variable?

    Hello,

    I am trying to write a little javascript program that runs on a local computer which will test if a website has high load or not.

    So the javascript running on the Windows 7 computer needs to "call" a URL like this:

    http://www.domain.com/load.php

    The "load.php" file just has output like this:

    1.0,2.0,3.0

    (This is the 1/5/15 minute load averages.)

    How can I get this webpage file output into a javascript variable?

    Thanks!
    - A simple online WYSIWYG editor for HTML code snippets.
    - Managed Web Hosting - $3.95/month (resellers welcome)
    - Why pay more? $8.95 domains & $9.95 SSL certificates!

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by hstraf View Post
    How can I get this webpage file output into a javascript variable?

    Thanks!
    The HTML-People example from the Bulletproof Ajax code page is a good example of how that is done.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was not able to figure out how to do this... Can anyone post some sample javascript code?

    Basically.. something similar to "get_file_content()" function in PHP.

    ie:

    page_value = get_file_content(http://www.mywebsite.com/page.html);

    Is this possible?

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    I also see at the microjs web site that there is an Ajax section, inside of which is one called MicroAjax that seems to do the job well.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    I also see at the microjs web site that there is an Ajax section, inside of which is one called MicroAjax that seems to do the job well.
    That worked great. Thanks!
    - A simple online WYSIWYG editor for HTML code snippets.
    - Managed Web Hosting - $3.95/month (resellers welcome)
    - Why pay more? $8.95 domains & $9.95 SSL certificates!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •