【发布时间】:2012-02-09 09:54:20
【问题描述】:
我通过 JSON 从 state.jsp 接收数据,并在 ID 为 textbox2 的文本框中显示 auto.jsp 中的数据。但我无法编辑接收数据的文本框,为什么?
//auto.jsp:
$("#combo1").change(function() {
// by onchange event of combobox, i am displaying string "anyname"
// on that below textbox.
$.getJSON('state.jsp', { combo1Val : $(this).val() }, function(responsedata) {
$("#textbox2").replaceWith(responsedata.name);
});
});
// i am displaying "anyname" here, but why i am not able
// to edit this text box after displaying? I have not set it to readonly
<input type="text" id="textbox2" name="2ndtextbox/>
//state.jsp
<%@page import="net.sf.json.JSONObject"%>
<%@page import="net.sf.json.JSONArray"%>
<%
JSONObject arrayObj= new JSONObject();
arrayObj.put("name","anyname");// displaying "anyname" in that textbox
response.setContentType("application/json");
response.getWriter().write(arrayObj.toString());
%>
我在该文本框中显示字符串“anyname”,但我无法再编辑此文本框,为什么?我没有将其设置为只读。任何帮助
【问题讨论】:
标签: javascript jquery ajax json