SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict lmasi02's Avatar
    Join Date
    Aug 2004
    Location
    Zambia
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    'XMLHttpRequest' is undefined

    Dear Gurus,

    i have a javascript am trying to run on command prompt but is failing. it is giving me the error "'XMLHttpRequest' is undefined". here below is the sample code
    var url="http://localhost/sms?username=u&password=p&from=111&text=test&to=27788988988 ";
    httpGet(url);
    function httpGet( the_url ){
    var httpRequest = new XMLHttpRequest();
    httpRequest.onreadystatechange = function() { alertContents(httpRequest); };
    httpRequest.open("GET", the_url, true);
    httpRequest.send(null);
    }
    where am i going wrong
    Power of Knowledge

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,799
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by lmasi02 View Post
    i have a javascript am trying to run on command prompt
    You are trying to use JavaScript commands that are only available when it runs in a web page.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Member
    Join Date
    May 2013
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are testing in old IE versions, it doesn't support XMLHttpRequest. Instead it supports XDomainRequest for ajax. However, recent IE versions (after 8 I suppose) support both objects.

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,799
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by gamish View Post
    If you are testing in old IE versions, it doesn't support XMLHttpRequest. Instead it supports XDomainRequest for ajax. However, recent IE versions (after 8 I suppose) support both objects.
    That's completely wrong -IE7+ all support XMLHttpRequest.

    XDomainRequest was introduced in IE8 as a proprietary way to make cross domain calls. Unless you are trying to access someone else's server with the call you should use XMLHttpRequest which all current browsers support (in web pages).
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    SitePoint Member
    Join Date
    May 2013
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry...
    I meant XMLHttpRequest Level 2 to be exact.


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
  •