getting json data using jquery ajax on jsp page
How do i get json data using jquery ajax on jsp page.Please can anyone suggest me some function 开发者_如何学JAVAfor it.I have to pass data coming from servlet to javascript like var data={"some json data"}
Seems like the jQuery docs for jQuery.getJSON() has examples.
1) Add JQuery into your page: http://jquery.com/
2) Use the getJSON method to call back to the server-side JSP page to retrieve the JSON data: http://api.jquery.com/jQuery.getJSON/
3) If you want to parse the JSON data into an object, use Douglas Crockford's JSON library: https://github.com/douglascrockford/JSON-js
Yes, you should retrieve from servlet the json string, and read it using a function like getJSON
$.getJSON('ajax/json_data.php', function(data) {
// do whatever you need with data
});
精彩评论