我有這樣的代碼片段(不一定完整,忽略結束腳本標籤)::通過jquery ajax爲datagrid加載數據?
<script type="text/javascript">
function gotoa(){
var h = $.get("http://localhost:8080/2_8_2012/jsp/GetJson.jsp", function(result) {
});
alert(result);
var myVar= h;
var storedata={
identifier:"ID",
label:"name",
items: myVar
};
var store = new dojo.data.ItemFileWriteStore({data: storedata});
爲GetJson.jsp的代碼::
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="MyPackage.PopulateTextbox" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<%
String temp1;
PopulateTextbox obj = new PopulateTextbox();
temp1 = obj.method();
%>
<%=temp1 %>
</head>
<body>
</body>
</html>
我第j查詢get方法。我傳入的URL返回一個Json數組字符串。 URL的輸出::
[{"ID":1,"Names":"Shantanu","Email":"[email protected]"},{"ID":2,"Names":"Mayur","Email":"[email protected]"},{"ID":3,"Names":"Rohit"},{"ID":4,"Names":"Jasdeep"},{"ID":5,"Names":"Rakesh","Email":"[email protected]"},{"ID":6,"Names":"Divyanshu"},{"ID":8,"Names":"hello"},{"ID":9,"Names":"fine"},{"ID":10,"Names":"shivani"}]
現在我想這個輸出爲我的數據網格即我想,VAR myVar的應該得到這個值,然後將上dojo.data.ItemFileWriteStore傳遞。我無法這樣做。請幫忙 ?謝謝。
我喜歡「請幫忙嗎?」中的問號標記 – joidegn 2012-03-14 12:39:49