-1
傢伙,我知道那是假的問題,但我想了很多,從來沒有達到過。這裏是在jsp中構造與參數在JavaScript
<button type="button" onclick="loadDepartment();" id="dep">Departments</button>
function loadDepartment(){
$(document).ready(function() {
$.ajax({
url : '/Spring3HibernateApp1/indexDep',
type : 'GET',
error : function(that, e) {
alert(e);
},
success : function(data) {
var newData = data.MyListDep;
gridDep = new GridLibraryDep({data: newData});
gridDep.display();
}
});
});
}
我的代碼 ,這在我的JS
function GridLibrary(data) {
\t \t this.data = data;
\t \t this.columns = $.map(this.data[0], function(item, key) {
\t \t \t return key;
\t \t });
\t \t this.pageSize = 5;
\t \t this.endIndex = startIndex + this.pageSize;
\t \t document.getElementById("from").innerHTML = 1;
\t \t document.getElementById("to").innerHTML = this.pageSize;
\t \t document.getElementById("total").innerHTML = data.length;
\t \t $("#first").click(bindContext(this.first, this));
\t }
GridLibrary.prototype = {
\t \t first : function() {
\t \t \t var size = this.data.length;
\t \t \t page = 1;
\t \t \t // document.getElementById("lbl").innerHTML = page;
\t \t \t this.endIndex = page * this.pageSize;
\t \t \t startIndex = this.endIndex - this.pageSize;
\t \t \t this.deleteTable();
\t \t \t document.getElementById("from").innerHTML = 1;
\t \t \t document.getElementById("to").innerHTML = this.endIndex;
\t \t \t document.getElementById("total").innerHTML = size;
\t \t \t this.display();
\t \t }}
所以我的問題是如何更新JS文件以這種方式被調用(數據:newData)?
JSP的價值並沒有任何關係做JavaScript,我已經爲你刪除了標籤。 –
誤導性標題 –