I love java
City: js var p = $ ('# province'). val (); $ ('# province'). change (function () { p = $ ('# province'). val (); $. ajax ({ type: "post", url: "ajax.action", data: {"id": p}, dataType: "html", success: { } }); jsp String id = request.getParameter ("id"); String sql = "select * from city where city.province =" + id; ResultSet rs = stmt.executeQuery (sql); I want to put in the jsp check out from the database into json format data analysis shows front and back, how should write ------ Solution ----------- --------------------------------- do not want to use the library, then assemble it yourself by json format returned back on the line! ------ Solution ---------------------------------------- ---- to be found in the data assembled by this format as a string, for example: [{'cityname': 'Beijing'}, {'cityname': 'Shanghai'}, {'' cityname ' : 'Nanjing'}, ...]. Then modify the ajax dataType "json". ------ Solution ---------------------------------------- ---- JSONObject json = new JSONObject (); JSONObject json = new JSONObject (); $. Ajax ({ type: 'POST', async: false, url:, global: false, success: function (data) { var dataObj = eval ("(" + data + ")"); if (dataObj.result == "success") { fal = true; } Else { } } }); ------ For reference only ---------------------------------- ----- never used json, how should assemble, seeking guidance ------ For reference only --------------- ------------------------ json.put ("result", "success" );
js var p = $ ('# province'). val (); $ ('# province'). change (function () { p = $ ('# province'). val (); $. ajax ({ type: "post", url: "ajax.action", data: {"id": p}, dataType: "html", success: { } }); jsp String id = request.getParameter ("id"); String sql = "select * from city where city.province =" + id; ResultSet rs = stmt.executeQuery (sql); I want to put in the jsp check out from the database into json format data analysis shows front and back, how should write ------ Solution ----------- --------------------------------- do not want to use the library, then assemble it yourself by json format returned back on the line! ------ Solution ---------------------------------------- ---- to be found in the data assembled by this format as a string, for example: [{'cityname': 'Beijing'}, {'cityname': 'Shanghai'}, {'' cityname ' : 'Nanjing'}, ...]. Then modify the ajax dataType "json". ------ Solution ---------------------------------------- ----
JSONObject json = new JSONObject (); JSONObject json = new JSONObject ();
$. Ajax ({ type: 'POST', async: false, url:, global: false, success: function (data) { var dataObj = eval ("(" + data + ")"); if (dataObj.result == "success") { fal = true; } Else { } } });
json.put ("result", "success" );
没有评论:
发表评论