Ajax Talk - Asynchronous javascript and xml discussion board
 FAQ   Search    Usergroups      Register   Profile   Check your messages   Log in 
Signup now to enjoy a range of free membership advantages !!
Ajax Talk - Moderators Wanted
1st day with ajax .. any help ?

 
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX general discussion
View previous topic :: View next topic  
Author Message
Jadelrab
New one
New one


Joined: 02 Jun 2006
Posts: 4
Location: Tanta. Egypt

PostPosted: Sat Jun 03, 2006 2:21 pm    Post subject: 1st day with ajax .. any help ? Reply with quote

hello,
it is very nice to find such a forum for ajax .. and it is in good design too Smile
it is still my first date ( yes it is date Smile ) with ajax so i'm still mixed up with it ..
i tried to copy the code from a book ( and run in it using apache ) i made the html page and the java file as they mentioned in it and put them in the same dir. and point the browser to the html file it ran well but with no ajax and no code works !!!
the question :
*does it nead a special settings to run ajax?
*does it require a framework to be installed to run ? ( as .net in asp.net )

and i use suse 9.3 Linux 2.6.11.4-21.12-default with apache2 and php 4.3.10

thanks alot!
sorry for my poor english!
Back to top
View user's profile Send private message Visit poster's website
deejay
Forum Assistant
Forum Assistant


Joined: 17 May 2006
Posts: 78
Location: Netherlands

PostPosted: Tue Jun 06, 2006 2:54 am    Post subject: hi Reply with quote

usually there are some javascript includes, so do you mean javascript or java ?

do you have a line in your html to refer to this javascript file ?

can you post back your code ?

ciao. dj
_________________
please correct me if i am wrong
seo-expertglobalwarming
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Jadelrab
New one
New one


Joined: 02 Jun 2006
Posts: 4
Location: Tanta. Egypt

PostPosted: Tue Jun 06, 2006 6:54 am    Post subject: Reply with quote

thanks for your reply ..
it is java file not javascript .. the code is

* the html file (validation.html) :
Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >

<html>
<head>
<title>Using Ajax for validation</title>
<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function validate() {
createXMLHttpRequest();
var date = document.getElementById("birthDate");
var url = "ValidationServlet?birthDate=" + escape(date.value);
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = callback;
xmlHttp.send(null);
}
function callback() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
var mes = xmlHttp.responseXML.getElementsByTagName("message")[0].firstChild.data;
var val = xmlHttp.responseXML.getElementsByTagName("passed")[0].firstChild.data;
setMessage(mes, val);
}
}
}
function setMessage(message, isValid) {
var messageArea = document.getElementById("dateMessage");
var fontColor = "red";
if (isValid == "true") {
fontColor = "green";
}
messageArea.innerHTML = "<font color=" + fontColor + ">"
 
+ message + " </font>";
}
</script>
</head>
<body>
<h1>Ajax Validation Example</h1>
Birth date: <input type="text" size="10" id="birthDate" onchange="validate();"/>
<div id="dateMessage"></div>
</body>
</html>


* the java file (ValidationServlet.java) :
Code:

package ajaxbook.chap4;
import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import javax.servlet.*;
import javax.servlet.http.*;
public class ValidationServlet extends HttpServlet {
/** Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
boolean passed = validateDate(request.getParameter("birthDate"));
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");
String message = "You have entered an invalid date.";f (passed) {
i
message = "You have entered a valid date.";
}
out.println("<response>");
out.println("<passed>" + Boolean.toString(passed) + "</passed>");
out.println("<message>" + message + "</message>");
out.println("</response>");
out.close();
}
/**
* Checks to see whether the argument is a valid date.
* A null date is considered invalid. This method
* used the default data formatter and lenient
* parsing.
*
* @param date a String representing the date to check
* @return message a String representing the outcome of the check
*/
private boolean validateDate(String date) {
boolean isValid = true;
if(date != null) {
SimpleDateFormat formatter= new SimpleDateFormat("MM/dd/yyyy");
try {
formatter.parse(date);
} catch (ParseException pe) {
System.out.println(pe.toString());
isValid = false;
}
} else {
isValid = false;
}
return isValid;
}
}


it works well with html file but after calling the java file it raise up an error
i don't know any thing about java files Smile ..

thanks again
Back to top
View user's profile Send private message Visit poster's website
adam
New one
New one


Joined: 31 May 2006
Posts: 4

PostPosted: Tue Jun 06, 2006 7:22 am    Post subject: Reply with quote

You need to understand that:

Java is NOT the same as JavaScript

Infact they are complete different in so many ways, javascript is a slow light client side scripting language. Java is a powerful programming language.

If you dont know anything about java why are you using java as the backend logic? You would be better using PHP, enless you have gotten mixed up with Java and JavaScript.

What is the error message you get as it looks like your Java might be wrong, I take it you have compiled your Java servlet, and installed TomCat as well?




Adam
Back to top
View user's profile Send private message MSN Messenger
Jadelrab
New one
New one


Joined: 02 Jun 2006
Posts: 4
Location: Tanta. Egypt

PostPosted: Tue Jun 06, 2006 3:44 pm    Post subject: Reply with quote

Dear Adam;
thanks for your reply ..
i know that java is not javascript .. i already use php and asp to create web pages but i as said before don't know any thing about java .. i before knowing any thing about ajax i thought that ajax is a technology similar to javascript but it need java to be run .. so i didn't get the point that ajax can work with php or any serverside script than java so i tried to run it with apache as i mentioned and it didn't work ..
btw: if you know any good book that use php with ajax for beginners i will be grateful and i already tried to get ajax 4 dummies and i will read it asap isa ..

sorry for bothering you but it is a silly question from the first day with ajax Smile
you will be surprised from the progress i made since it Smile ..

see you , and thanks very much
Back to top
View user's profile Send private message Visit poster's website
clenard
Light Frequent Poster
Light Frequent Poster


Joined: 25 Jun 2006
Posts: 9

PostPosted: Sun Jun 25, 2006 11:45 pm    Post subject: Reply with quote

Jadelrab wrote:
Dear Adam;
thanks for your reply ..
i know that java is not javascript .. i already use php and asp to create web pages but i as said before don't know any thing about java .. i before knowing any thing about ajax i thought that ajax is a technology similar to javascript but it need java to be run .. so i didn't get the point that ajax can work with php or any serverside script than java so i tried to run it with apache as i mentioned and it didn't work ..
btw: if you know any good book that use php with ajax for beginners i will be grateful and i already tried to get ajax 4 dummies and i will read it asap isa ..

sorry for bothering you but it is a silly question from the first day with ajax Smile
you will be surprised from the progress i made since it Smile ..

see you , and thanks very much


Hey Jadelrab,

I'm not sure if you have figured any of this out as this thread is old but have you gotten the ajax for dummies book yet? The book is very helpful and uses PHP to get you going.

Another good book is AJAX in Action by Manning. You should definately check that book out when you're done with the dummies book. Together, I think you'll learn all you need to know to get your AJAX projects going Razz
Back to top
View user's profile Send private message
Jadelrab
New one
New one


Joined: 02 Jun 2006
Posts: 4
Location: Tanta. Egypt

PostPosted: Mon Jun 26, 2006 1:12 am    Post subject: Reply with quote

Dear Clenard,

thanks for your Interest and your kind reply ..
i already got the for dummies book and start reading it , some delay was happen cause of the final exams of the year .. i will finish it isa ..
and thanks for this recommendation (Ajax in action) i will try to get it too ..

sorry for my poor english ..
see you..
Back to top
View user's profile Send private message Visit poster's website
clenard
Light Frequent Poster
Light Frequent Poster


Joined: 25 Jun 2006
Posts: 9

PostPosted: Tue Jun 27, 2006 2:01 am    Post subject: Reply with quote

Jadelrab wrote:
Dear Clenard,

thanks for your Interest and your kind reply ..
i already got the for dummies book and start reading it , some delay was happen cause of the final exams of the year .. i will finish it isa ..
and thanks for this recommendation (Ajax in action) i will try to get it too ..

sorry for my poor english ..
see you..


No problem with the english - mine might be worse than anybody's and I live in the U.S. Razz

Good luck with the Dummies book. I've went back to learn a little more through that book. It's pretty good!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX general discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
 Advertisements
 XML & Copyright Notice 
    


Powered by phpBB © 2001, 2005 phpBB Group

What is according to Wikipedia: Ajax Web2.0 XML E4X


Link to our site:

  


del.icio.us digg spurl wists simpy newsvine blinklist furl blogmarks yahoo! myweb smarking ma.gnolia segnalo reddit fark technorati cosmos


Normal Bookmark


Partner Button Links:
Codecrunch.com: Webmaster Tutorials    One Ajax


Partner Text Links:
quomon | web20log | ajaxmatters | tableless | 456bereastreet | music charts | gift ideas | competitions | free xbox 360 | link trade ?


Credits:
it consultancy & project management lead generation zoekmachine optimalisatie steal these buttons seo expert