我有这个代码:
$(document).ready(function() {
$('#inverter_err').change(function() {
var qString = 'err=' +$(this).val();
$.post('err_query.php', qString, processResponse);
});
function processResponse(data) {
if(data != "false") {
$("#result").html(data).show("slow");
}
else {
$("#result").hide("slow");
}
}
});
当 err_query.php(这是一个简单的 sql 查询,生成 echo json_encode($array);)得到肯定结果时
,结果将显示为 ["The结果”]
。
如何删除 [""]
?我只需要显示文本。
最佳答案
它看起来像返回一个 JSON 数组,所以:
var value = JSON.parse(data)[0];
关于jquery - 如何从 json 输出中删除 [""]?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16224430/