2014年1月2日星期四

How to read data from the database using jquery

Help heroes ah , my needs are :
inside the jsp page , click the query , and then use jquery check out the data from the database and then displayed on a table inside the jsp page , there are several fields in which the database to be displayed, for example : id , name, age, sex , etc.
I was a rookie , heroes seeking answers , it is best to give a concrete example . I am grateful !
------ Solution ---------------------------------------- ----
jQuery is a web -side execution , the database query is a server-side , jQuery can not access the database

using AJAX, jQuery send a message to the server , so the server-side Servlet Access database query , and then return the data to the jQuery
------ Solution ----------- ---------------------------------
can use JQuery Ajax to query the database to generate the background Json data format can be yourself , you can also use JQuery inside comes , if do not understand Baidu, using Json data.
------ Solution ---------------------------------------- ----

he meant not that make you spend jquery it? jquery can not directly interact with the database , or action will certainly spread
------ Solution ----------------------------- ---------------
JQuery can not take the data , you can use JQuery Ajax to query the database to generate Json data back , then return to the page
- ---- Solution -------------------------------------------- < br> ajax call to action or servlet returned with a database of information structure json
------ Solution ---------------------- ----------------------
$.ajax({
   type: "POST",
   url: "some.php",
   data: "name=John&location=Boston",
   success: function(msg){
     alert( "Data Saved: " + msg );
   }
});

------ Solution ------------ --------------------------------
I've done this example I'll teach you
I see the value you get is a list of the right
However, the exact value of jquery json format
must be converted
String jsonArray = JSONArray.toJSONString ( This is a list object ) ;
pass jsonArray to jsp
then inside jquery
dataType: 'json',
I sink down slightly with the
success: function (data) {
$ (data). each (function (i, name) {
alert (name.id);
alert (name. property name ) ;
So looping through out the OK
}
------ For reference only --------------------------------- ------
what technology to use , oh ? Or on a jsp . . .
------ For reference only ---------------------------------------
company call me today with jquery to read data from a database table and then display it, then he is what does that mean? In fact, I do not quite understand this , is to send a request to the action side of the query and return a json it? That follows the action there and then query the data side of the page to read there is no difference between you !
For example, I now want to be a provincial cascading drop-down list. Among cities and provinces are on the database , and I would like to read out using js inside ajax technology which is then displayed in the drop-down list , right?
------ For reference only -------------------------------------- -
jquery ajax access action doing the chanting .
------ For reference only -------------------------------------- -
view is jsp, hibernate query the database using the controller is springmvc.
I mainly do not understand what he said with jquery query data out what it meant, but also to query the server that is not it?
------ For reference only -------------------------------------- -

this is ah jquery is asynchronous, give us a lot of convenience
------ For reference only --------- ------------------------------
ah , thank you, but I sent an AJAX request , the data can also check out the but now there is a problem is how to return a json it? I want to return a list collection to js inside iteration , but do not know how to return the callback function and no callback ...... what is the problem
------ For reference only ---- -----------------------------------
  The reply was deleted at the moderator 2011-12-21 09:03:10

------ For reference only ---------------------------------- -----


I mean from the server side how to return JSON object to jsp, I tried for a long time did not try out !
------ For reference only -------------------------------------- -


I just tried it , looks like no JSONArray.toJSONString (list) this method, only JSOArray.toList (json object ) ; this method , the problem is still not solved ......
----- - For reference only ---------------------------------------
seemingly no JSONArray.toJSONString (list)
need json-lib-2.3-jdk15.jar
------ For reference only ---------------------- -----------------


This package there : json-lib-2.2.3-jdk15.jar
------ For reference only ------------------ ---------------------
with a web service on the line

没有评论:

发表评论