AJAX REQUEST TO SERVER [Sending data to Servlet by AJAX call ]

1. create one web application : example - TestAjax.

To create new Web Application in net beans Perform following Steps

Open Netbeans  -> Select File -new - >Java Web Peoject - >Name To the project[ex. TestAjax]  - Finish.

2. create one jsp file example :index.jsp and write a code .

download Jquery library and add it in your project. 

<head>
<script src="text/javascript">
</script>
</head>
<form id="myform">
name:<input type="text" name="name" id="name">
email :<input type="text" name="email" id="email">
<input type="submit" value="registration" id="button1">
</form>

<script type="text/javascript">
 $(document).ready(function(){
 $('button1').click(function(e){
 var name=$('#name').val();
var email=$('#email').val();
$.ajax({
 type:"GET",
url:"reg",
data:"name="+name+ "&email="+email,
success:function(msg){
alert("success");
},
error:function(e){
 alert("error);
}
});
});
});
</script>


Create One Servlet [With uRL pattern == reg]

// write  following code inside body tag of process Request method.

String name=request.getParameter("name");
String password=request.getparameter("password");

= Call Me Or Whats App - 9561826040 .. If U face any Problem.



Comments

Post a Comment

Popular posts from this blog

Filter In Javafx

Kotlin with StandAlone Complier