• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is that any sample code for Ajax which implement in jsp ?

 
Nakata kokuyo
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, good day, is there any simple sample code for ajax implementation in java environment ? for example, checking existing product code in database

thank you
 
Surya Kant
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hope this would help you...

function validate(url)
{
if (window.ActiveXObject)
{
request = new ActiveXObject("Microsoft.XMLHTTP");
request.onreadystatechange = checkForResult;
if(request)
{
request.open("GET", url);
request.send();
}
}
}

function checkForResult()
{
// If req shows "loaded"
if (request.readyState == 4)
{
// if response is "OK"
if (request.status == 200)
{
//this is a response sent from server program
//get this reponse & do the operations accordingly
var response = request.responseText;
}
// Server not responding . It might have been stopped
else
{
//stopScripts('Server not Responding');
}
}
}

function setURL()
{
if(validatePass())
{
var url = form some url which u want send to server
validate(url);

}
}
 
Gerardo Tasistro
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try DWR

http://getahead.ltd.uk/dwr

Very easy to use. You just include the libraries as explained, setup some classes in your server and do some configuration. In a few minutes you'll be able to call your classes' methods from JavaScript.

See this

http://getahead.ltd.uk/dwr/examples/address
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
surya mm,

your code is IE only......better make it work with all browsers!

Eric
 
Nakata kokuyo
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks all for warm reply and guidance
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic