CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2009
    Posts
    1

    Ajax Help with returning value

    I'm trying to setup a ajax structure in my HTML form and I'm getting an error "syntax error - line 1" in my AjaxServer.php file. The file has nothing in it yet except a test string to make sure I have all my ajax code working in my form.

    PHP script on the Server side:
    PHP Code:
    <?php 
    session_start
    (); 
    $php_return_status "test"
    echo 
    $php_return_status
    ?>
    My form ajax code in the JS section:
    Code:
    function ajax_test_click()
    {
        http.open('get', 'Server.php', true);
        http.onreadystatechange = returnAjaxData;
        http.send(null);
    }
    function returnAjaxData()
    {
        if (http.readyState == 4)
           {
             if (http.status == 200)
                {
                  var response = http.responseText;
                  alert(response);
                }
             else
                {
                  alert("Ajax error: " + http.statusText);
                }
           }
    }
    I get the JS dialog box ok which displays "Test" but I'm also getting a Firefox Error Console display of "Syntax error - line 1" and an arrow pointing to the word 'test'.

    Does anyone know what might be causing this error?
    Last edited by PeejAvery; February 15th, 2009 at 09:26 PM. Reason: Added code tags.

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: Ajax Help with returning value

    Well, there is absolutely nothing wrong with the code you have posted.

    If Firefox's Error Console is detecting it, that means it is a client-side error which means that pointing to the word "test" makes no sense.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Oct 2008
    Posts
    29

    Re: Ajax Help with returning value

    Every website I go to gives FireFox's console errors. So I doubt anything is wrong with your code.
    Plus it all looks valid.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured