1

I have one table in mysql which has three field with data inserted. there are three fields in it which are as below. this is snapshot of a database, table and inserted field in it

i want to display this data on a web browser with using ajax in java.

i search on a net and find this below code are most useful

Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/ajax_demo","root","");  
PreparedStatement ps=con.prepareStatement("select * from ajax");

what are other things i have to implement for displaying output.

1
  • Naming your table ajax is just going to confuse you. Ajax is just a javascript technology to send a HTTP request to a page on your webserver. Commented May 14, 2014 at 17:09

1 Answer 1

1

You need to do a AJAX request, the main code body for an ajax request is the following

request.onreadystatechange=handleResponse;
request.open(typeReq, url, true);
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
request.send(queryString);

typeReq is the type of the request: POST or GET. url: the destination url address. queryString: the set of data which you want to send.

handleResponse is a function to hanled the response. For example:

function handleResponse () {
if (request.readyState = 4) {
if (request.status = 200) {
var response = request.responseText;
//code to handle response
} else {
//code to handle errors
}
}

Now, you can use an API like prototype or jquery, it's easier.

I hope this information helps you.

Good Luck

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.