1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Javascript return doesn't work?

Discussion in 'Programming & Webmastering' started by aximbigfan, Mar 30, 2008.

  1. aximbigfan New Member

    Joined:
    Oct 15, 2006
    Messages:
    848 (0.29/day)
    Thanks Received:
    35
    Location:
    St. Louis, MO
    I have been trying for a long time, I just want this function to return a var, but no matter what, it doesn't work.

    Code:
    function ajax(url)
    {
    var http = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
    
    http.onreadystatechange = function()
    {
    if (http.readyState == 4)
    {
    if (http.status == 200)
    {
    return http.responseText;
    }
    else
    {
    alert("AJAX Error! \nReturned Text: "+ http.statusText);
    }
    }
    }
    
    http.open("GET" ,url , true);
    http.send(null);
    }
    Anyone?

    Thanks,
    Chris
     

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page