【发布时间】:2014-12-05 18:18:47
【问题描述】:
我的 ajax 脚本将 json 对象发送到浏览器,但表无法加载 json 对象。 我的 Ajax 脚本:
$.ajax({
type : "POST",
url : "getLabels.jsp",
data : "mailingID=" + selectedValue, // posCodeSelected
success : function(data) {
response = $.parseJSON(data);// this statement sends data succesfully to browser
},
error : function(response) {
var responseTextObject = jQuery.parseJSON(response.responseText);
}
});
这是嵌入到我的 jsp 页面中的引导表。
<table data-height="299" data-show-refresh="true" data-show-toggle="true" data-show-columns="true" data-search="true" data-select-item-name="toolbar1">
<thead>
<tr>
<th data-field="rowNumber" >ID</th>
<th data-field="firstname" >first name</th>
<th data-field="lastname" >last name</th>
<th data-field="organization" >organization</th>
<th data-field="city" >city</th>
<th data-field="state" >state</th>
</tr>
</thead>
</table>
只是为了让你们现在这是我在浏览器中的 json 响应:
{"rowNumber":1,"mailingID":3,"firstname":"Brian","lastname":"Fairhurst","organization":"Florida State University","city":"Tallahassee","state":"FL"}
【问题讨论】:
-
解析 JSON 后,
response在做什么? -
这篇文章可能有帮助吗? stackoverflow.com/questions/25187349/…
-
@BlaiseSwanwick:是的,您提供的链接具有加载 json 文件的表属性 data-url="test.json"。但就我而言,我必须将 json 对象(响应)加载到表中。
-
那我会回答的。很高兴有帮助。
标签: javascript ajax json twitter-bootstrap jsp