-
February 15th, 2009, 06:41 PM
#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.
-
February 15th, 2009, 09:34 PM
#2
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.
-
February 17th, 2009, 05:34 PM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|