I'm trying to use the autocomplete widget to and to populate it I am using a servlet which is returning a JSON array. Bear with me, I'm not sure how much you need to see so I'm going to include a lot.
Here is how I am constructing the autocomplete right now. It's not complete yet because I don't really know how to finish:
Clearly I need to work on success, that's where my hold up is right now. Here is the servlet code that builds the JSON array. The data is coming out of a database using jdbc:
ResultSet result = stmt.executeQuery(); JSONArray array = new JSONArray(); while (result.next()) { JSONObject obj = new JSONObject(); obj.put("fullname", result.getString("fullname")); array.add(obj); } result.close(); stmt.close(); log.info(array.toJSONString()); out.print(array.toJSONString()); out.flush();
My output from this block of code shows this: [{"fullname":"andrea danziger"},{"fullname":"Stacey Moda"},{"fullname":"Debbie Jordan"},{"fullname":"Greg Jordan"},{"fullname":"Janet Randall"},{"fullname":"Arjun Ghosh-Dastidar"},{"fullname":"Brian Adamson"}]
This looks like a good JSON array to me, although I'll be the first to admit that I'm not an expert. So, what's the next step? The data is returning, I can see that clearly enough, but how do I parse it and return it to the autocomplete?
I am happy to return the JSON array however it needs to be constructed. I can also modify the options for the autocomplete.
I'd like to change the mouse cursor to a pointer for the rows in a particular table but I'm not having any luck getting it to work. Here are some of the things I have tried, but the cursor resolutely refuses to change for me:
I'm hoping someone can help me with a problem I am having. I am populating a tablesorter using ajax and the number of rows is quickly getting out of hand so I'd like to implement the tablsorterPager. This works fine when the table rows are included in the jsp page, but when I try to populate dynamically I am still getting all of the rows at once.
The url is a very straightforward servlet that queries a database and returns either Y or N. That part is working fine. The first alert shows Y or N just as it is supposed to. However, the second alert is always showing Turbo, as though the if statement is not able to compare properly. This is probably javascript rather than specific to jQuery, but can anyone see where I'm going wrong?
When this runs, if the first alert shows it is supposed to set runUpdate to false, as you can see. But when the second alert shows it is still equal to true. Am I missing something?
I am developing a web application in java (jsp's and servlets). That part is no problem, I have plenty of experience with that. But I am very new to using jQuery, so I am hoping I can get some help before I get myself into trouble.
For the project I am working on I will need to develop an html data entry screen and the code to load data into the screen, and then save the data back to the back-end database. I am hopeful that I'll be able to get some examples of how to do the following:
Read the data out of the database (JDBC, no problem) in a servlet.
Put the data into the appropriate form for returning to the data entry screen, which will be a jsp. (Is JSON the right choice for passing the data from the servlet to the jsp?)
In the jsp, parse the returned data and populate the HTML form elements (text fields and combo boxes).
When a button is clicked, pull the data out of the form elements and return to a servlet for saving back in the database.