Php 在jQuery accordion中显示JSON数据
我正在开发一个新的应用程序,并决定尝试使用jqueryeasyui来简化我的工作。我正在进步,但我肯定是疯了。这是一种随学随用的努力 我就在这里: 我已经能够提取基本的联系信息并将其填充到jQuery对话框窗口中。我正在使用选项卡和其中一个选项卡中的手风琴自定义对话框。我的问题是手风琴显示的是JSON,而我似乎无法格式化它 以下是本节的代码:Php 在jQuery accordion中显示JSON数据,php,jquery,json,jquery-easyui,Php,Jquery,Json,Jquery Easyui,我正在开发一个新的应用程序,并决定尝试使用jqueryeasyui来简化我的工作。我正在进步,但我肯定是疯了。这是一种随学随用的努力 我就在这里: 我已经能够提取基本的联系信息并将其填充到jQuery对话框窗口中。我正在使用选项卡和其中一个选项卡中的手风琴自定义对话框。我的问题是手风琴显示的是JSON,而我似乎无法格式化它 以下是本节的代码: function editUser(){ var row = $('#dg').datagrid('getSelected');
function editUser(){
var row = $('#dg').datagrid('getSelected');
if (row){
$('#dlg').dialog('open').dialog('setTitle','Prospect Details');
$('#fm').form('load',row);
url = 'update_user.php?id='+row.id;
$('#dia_name').html(row.Name);
var phone = phoneFormat(row.Phone);
$("#dia_phone").html(phone);
if (row.message_duration > 0) {
$('#hangup').hide();
$('#message').show();
$('#msg_txt').show();
} else {
$('#hangup').show();
$('#message').hide();
$('#msg_txt').hide();
}
var pp = $('#aa').accordion('getSelected'); // get the selected panel
if (pp){
pp.panel('refresh','contact_history.php?phone='+row.Phone); // call 'refresh' method to load new content
var txt1=$("<p>Time: ").text(contact_dt);
var txt2=$("</p><p>Method: ").text(method);
var txt3=$("</p><p>Who: ").text(who);
var txt4=$("</p><p>Note: ").text(note);
$("#hist_title").append(txt1);
$("#hist_item").append(txt2,txt3,txt4);
}
}
}
函数editUser(){
变量行=$('#dg')。数据网格('getSelected');
国际单项体育联合会(世界其他地区){
$('dlg')。对话框('open')。对话框('setTitle','Prospect Details');
$('#fm').form('load',row);
url='update_user.php?id='+row.id;
$('#dia_name').html(row.name);
var phone=phoneFormat(row.phone);
$(“#dia_phone”).html(phone);
如果(row.message_duration>0){
$(“#挂断”).hide();
$(“#消息”).show();
$('#msg_txt').show();
}否则{
$('#挂断').show();
$(“#消息”).hide();
$('#msg_txt').hide();
}
var pp=$('#aa')。accordion('getSelected');//获取所选面板
如果(pp){
pp.panel('refresh','contact_history.php?phone='+row.phone);//调用'refresh'方法加载新内容
var txt1=$(“Time:”).text(联系方式);
var txt2=$(“方法:”).text(方法);
var txt3=$(“Who:”).text(Who);
var txt4=$(“注:”).text(注);
$(“历史名称”)。附加(txt1);
$(“历史项目”)。追加(txt2、txt3、txt4);
}
}
}
以下是手风琴的HTML部分:
<div id="aa" class="easyui-accordion" style="width:300px;height:200px;">
<div title="Title1" data-options="iconCls:'icon-save'" style="overflow:auto;padding:10px;">
<p>Test</p>
</div>
<div id="hist_item" title="Title2" data-options="iconCls:'icon-reload',selected:true" style="padding:10px;">
content2
</div>
<div title="Title3">
content3
</div>
</div>
试验
内容2
内容3
那么现在…我在这里犯了什么难以置信的明显和愚蠢的错误?再次提前感谢您帮助我解决这个问题。无论您的JSON来自何处,您都必须首先解析它:
var data=JSON.parse(incomingData)代码>
然后,它是一个数组,您可以随意执行:
$(“#历史标题”).append(数据['title')代码>
或
$(“#历史标题”).text(数据['title')代码>JSON应该在哪里读取?如何从服务器获取数据。。?