Obi1-Cannabis Posted January 19, 2007 Share Posted January 19, 2007 i'am trying just a simple test to see how to work with AJAXthis is my code:HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <script src="login.js"></script> </head><body><table width='250'> <tr><td align='right'> <fieldset> <legend> Detect </legend> <form action='post'> <p> NAME: <input type='text' name='ident' id='ident' onblur="checkid()"/> </p> <p> JOB: <input type='text' name='pass' id='pass'/> </p> </form> </fieldset> </td></tr></table></body></html> JScript var url = "getPass?id="; // The server-side scriptfunction handleHttpResponse() { if (http.readyState == 4) { document.getElementById('pass').value = results; }}function checkid(){ var id = document.getElementById("ident").value; http.open("GET", url + escape(id), true); http.onreadystatechange = handleHttpResponse; http.send(null);}function getHTTPObject() { var xmlhttp; @cc_on @if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @else xmlhttp = false; @end @ if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; } } return xmlhttp;}var http = getHTTPObject(); PHP <?php echo "Painter"; ?> but it gives an error on page saying i have an invalid character on line 33. i don't get it. Link to comment Share on other sites More sharing options...
javalessons Posted January 20, 2007 Share Posted January 20, 2007 Did you test it in IE, since you're using IE-specific conditional compilation : @cc_on, @if, etc. ? Link to comment Share on other sites More sharing options...
Obi1-Cannabis Posted January 22, 2007 Author Share Posted January 22, 2007 yes, i only tested in IE Link to comment Share on other sites More sharing options...
Beta Posted January 22, 2007 Share Posted January 22, 2007 http://www.javascriptkit.com/javatutors/co...alcompile.shtml'...Include comment tags in your script in a way that ensures browser compatibility..." Link to comment Share on other sites More sharing options...
Obi1-Cannabis Posted January 23, 2007 Author Share Posted January 23, 2007 i got it to work, the only problem now is that it returns all the php tags such as 'echo' and so on... in the example i gave before its returning <?php echo "Painter"; ?>inside the job field...this isn't suposed to happen right? so what can be wrong? Link to comment Share on other sites More sharing options...
jesh Posted January 23, 2007 Share Posted January 23, 2007 Does the page render correctly when you type in the URL into your address bar rather than accessing it using AJAX? Try visiting "getPass?id=someid", if it still shows the PHP code, then you don't seem to have your server configured correctly to handle PHP without the .php extension. Link to comment Share on other sites More sharing options...
Obi1-Cannabis Posted January 23, 2007 Author Share Posted January 23, 2007 Does the page render correctly when you type in the URL into your address bar rather than accessing it using AJAX? Try visiting "getPass?id=someid", if it still shows the PHP code, then you don't seem to have your server configured correctly to handle PHP without the .php extension.yes i guess you were correct, the problem was my server configuration, to think i almost hit my head against the table...thanks Link to comment Share on other sites More sharing options...
Simulationcity Posted January 29, 2007 Share Posted January 29, 2007 Can you upload the final code because I'm trying to understand AJAX and it's not making any sense. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now