www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Return Problem

  1. #1
    Join Date
    Oct 2010
    Posts
    2

    resolved [RESOLVED] Return Problem

    I'm having a small issue with the following code. The text variable is coming up undefined when returning the ajax responseText. The alert(response); gives me what is in the echo.txt file but return doesn't seem to be working.

    PHP Code:
    var text ajax({
            
    'url' 'echo.txt'
        
    });

    alert(text); 
    PHP Code:
    function ajax(params)
    {
        var 
    args = { 'method' 'GET''url' 'echo.txt''async' true }
                
        if (
    params)
        {
            for (var 
    index in args) { if (typeof params[index] != 'undefined'args[index] = params[index]; }
        }
                
        var 
    http;
        if (
    window.XMLHttpRequest) { http = new XMLHttpRequest(); }
        else { 
    http = new ActiveXObject('Microsoft.XMLHTTP'); }
                
        
    http.onreadystatechange = function()
        {
            if (
    http.readyState == 4)
            {
                var 
    response http.responseText;
                
    alert(response);
                return 
    response;
            }
        }
                
        
    http.open(args['method'], args['url'], args['async']);
        
    http.send();

    Any help is appreciated.

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    Oct 2010
    Posts
    2
    Thanks :-) problem solved.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles