ajax code

Ads
 

ajax code

View Answers

October 30, 2009 at 11:54 AM

Hi Friend,

Try the following code:

1)ajax.jsp:
<html>
<body>
<script language="javascript" type="text/javascript">
function ajaxFunction(){
var ajaxRequest;
try{
ajaxRequest = new XMLHttpRequest();
}catch (e){
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
}catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
}catch (e){
return false;
}
}
}
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('ajaxDiv');
ajaxDisplay.value = ajaxRequest.responseText;
}
}
var name= document.getElementById("name").value;
window.open("http://localhost:8080/examples/jsp/insert.jsp?name="+name,"mywindow","width=500

, height=350,toolbar=no,resizable=yes,menubar=yes");

}
</script>
<form name="myForm">
Enter Name: <input type="text" id="name" /> <br />
<input type="button" onclick="ajaxFunction()" value="Insert"/>
</form>
</body>
</html>

2)insert.jsp:
<%@page import="java.sql.*"%>
<%
String name=request.getParameter("name");
out.println(name);
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";;;
String dbName = "register";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "root";

try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,userName,password);
Statement st = conn.createStatement();
int i=st.executeUpdate("insert into Person(name) values('"+name+"')");
}
catch(Exception e){}

%>

Thanks

Ads









Related Tutorials/Questions & Answers:
Ajax code
Ajax code   I want an ajax code in jsp where selecting a listbox changes the other selectbox values .Suppose take a country as one select box...); } %> For the above code, we have created two tables: 1)country: CREATE
ajax code
ajax code  Explain me this code function disp_branch(val) { if(unit_branch!=val){ unit_branch=val; xmlHttp=GetXmlHttpObject... not support HTTP Request") return } var url="index.php?q=<
Advertisements
ajax code for jsp
ajax code for jsp  How to write ajax code to retrieve information on to particular part of webpage when we select option from drop down box
simple ajax Request and Response code...
simple ajax Request and Response code...  var request=null; if (window.XMLHttpRequest) { request = new XMLHttpRequest(); } else... { alert("Your browser don't support AJax !"); } } else
ajax code please help to solve this........
ajax code please help to solve this.  in this i am trying to get data... and use ajax onchange but when i am trying to do so it show some error... the fourth one similarly. For the above code, we have used 3 database tables
Ajax Code Libraries and Tools
Ajax Code Libraries and Tools        Code libraries and loots for the development of your Ajax... or understand DHTML, Ajax or DOM code.     PAJAJ: PHP
i want horizontal mlm tree structure code in php with jquery or Ajax
i want horizontal mlm tree structure code in php with jquery or Ajax  i need horizontal mlm tree structure code in php with jquery or Ajax... in advance.. Thank you
how to generate reports from oracle database using jsp and ajax code
how to generate reports from oracle database using jsp and ajax code  Hai masters i am new to this Java world. my team leader ask me to generate... this send me a code to my email:[email protected] its a humble request my team
ajax
ajax  please describe the ajax
Ajax
Ajax  How to learn AJAX
Ajax
Ajax  Hi, What is Ajax? What is the use of Ajax? Thanks   Hi, Ajax is set of technologies used to develop dynamic web applications. In Ajax following technologies is used: a) JavaScript b) XML c) HTTP d) CSS Learn
Ajax
Ajax  how to impliment ajax in registration table using jsp-servlet
Ajax
Ajax  send the example to fetch the data from the server by using ajax in java. for ex:-if there are states which is used to display in frontend we use ajax. send it to me
ajax
ajax  how to connect ajax with mysql without using php,asp or any other scripting language. please answer soon
ajax
ajax  HI, In my application using ajax if i type a managername in the textbox it should display all the employees under the that manager... me reg this. thanks KK   Combobox box using Ajax in JSP   i
ajax
ajax  How can we fetch data in ajax through servlet?   "mainpage.jsp" <html> <head> <title>Ajax Example</title>...;/head> <body> <h1 align="center"><font color="#000080">Ajax
ajax
ajax  How can we fetch data in ajax through servlet?   "mainpage.jsp" <html> <head> <title>Ajax Example</title>...;/head> <body> <h1 align="center"><font color="#000080">Ajax
ajax
ajax  How can we fetch data in ajax through servlet?   "mainpage.jsp" <html> <head> <title>Ajax Example</title>...;/head> <body> <h1 align="center"><font color="#000080">Ajax
ajax
ajax  How can we fetch data in ajax through servlet?   "mainpage.jsp" <html> <head> <title>Ajax Example</title>...;/head> <body> <h1 align="center"><font color="#000080">Ajax
AJAX
ajax. My table is CREATE TABLE HTNEWMETER ( ID NUMBER (10) NOT NULL, METERNO...   Hi Friend, Try the following code: 1)radiobuttons.jsp: <%@page
Ajax
options. I want to do it using ajax. My table is CREATE TABLE HT<em>
ajax
ajax  I am facing following problem, I am using ajax to get the data continousely without refreshing. Here i have devided a web page into 3 parts... code. - split.jsp <html> <head> <script type
Ajax
Ajax  i am having code in my javascript file , I want to know what is the meaning of this function ajaxFunction(url, "1"); url is given here but what is 1 here means? function populateList(element) { //alert
ajax example
Ajax  Ajax - Ajax that : form1.html where all Ajax code... for get request? Give me code for jQuery ajax get request. Thanks ... Example  Hi, I want to validate my ajax form. Please give me good code
ajax programming
Ajax Code Libraries and Tools Ajax Chat Applications Ajax Books Ajax...Ajax Programming What is Ajax Programming? Asynchronous JavaScript and XML briefly known as Ajax is used to interchange the data with the server
Ajax demo
framework. All the Ajax demo is supported by downloadable code, which you can...Ajax demo  Hi, I am new to Ajax and I want to see the running example of Ajax examples. Various types of Ajax demo application will help me
AJAX Goals
AJAX Goals       AJAX site with forums, code samples, news and articles Read full Description
Ajax Links
Ajax Links       AJAX links, code samples and news Read full Description
AJAX with
AJAX with       Ajax resources, in a digg style, allows the user to register and addd his/her own links Read full Description
Ajax library
for creating Ajax applications easily. Ajax libraries contains many necessary code...Ajax library  Hi, What is Ajax Library? List down the latest ajax libraries. Thanks   Hi, Ajax allows the developers to build Ajax based
ajax news
Ajax Resources ; Ajax Links AJAX links, code samples and news    ... Ajax...Ajax news Welcome! to the News letter archive Welcome! to the News

Ads