Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/405.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用jquery解析phonegap中的json数据_Javascript_Jquery_Cordova_Jquery Mobile_Phonegap Desktop App - Fatal编程技术网

Javascript 使用jquery解析phonegap中的json数据

Javascript 使用jquery解析phonegap中的json数据,javascript,jquery,cordova,jquery-mobile,phonegap-desktop-app,Javascript,Jquery,Cordova,Jquery Mobile,Phonegap Desktop App,下面是我的json数据URL 我想使用jquery Mobile for Phonegap在表中显示数据。我可以轻松获取数据,但可以在手机上显示 下面是一个工作示例。请指导我如何为phonegap解析它 $(document).ready(function() { $.ajax({ url : 'http://bluestonesolutions.in/Connect4mJson/GetEmployees.svc/getnotice?InstanceId=604&

下面是我的json数据URL

我想使用jquery Mobile for Phonegap在表中显示数据。我可以轻松获取数据,但可以在手机上显示

下面是一个工作示例。请指导我如何为phonegap解析它

$(document).ready(function() {
    $.ajax({
        url : 'http://bluestonesolutions.in/Connect4mJson/GetEmployees.svc/getnotice?InstanceId=604&EnoticeType=Flash%20News&UserID=112730&IsGlobalNotice=0',
        type : 'GET',
        dataType : 'JSON',
        crossDomain: true,
        success : function(data) {      
            document.write('<table width="400" height="288" align="center"  style="border:5px solid #10A3D8; ">')
            $.each(data, function() {
                console.log(this.Subject);
                document.write('<tr style="background:#D4D2D2;" >')
                document.write('<td style="color:#041DB3;">'+'Subject:-</td>')
                document.write('<td style="color:#041DB3;">'+this.Subject+'</td>')
                document.write('</tr>')
                document.write('<tr style="background:#04A273;">')
                document.write('<td>'+'Description:-</td>')
                document.write('<td>'+this.ENoticeDescription+'</td>')
                document.write('</tr>')
            });
            document.write('<table>');          
            // open console debugging tools on google and see the parse value
        },
        error : function() {}
    });
});
$(文档).ready(函数(){
$.ajax({
网址:'http://bluestonesolutions.in/Connect4mJson/GetEmployees.svc/getnotice?InstanceId=604&EnoticeType=Flash%20News&UserID=112730&IsGlobalNotice=0',
键入:“GET”,
数据类型:“JSON”,
跨域:是的,
成功:函数(数据){
文件。写入(“”)
$.each(数据,函数(){
console.log(this.Subject);
文件。写入(“”)
文档。写入(“”+”主题:-'))
文件。书写(“”+此主题+“”)
文件。写入(“”)
文件。写入(“”)
文件。写入(“+”说明:-”)
document.write(“”+this.ENoticeDescription+“”)
文件。写入(“”)
});
文件。写(“”);
//在google上打开控制台调试工具并查看解析值
},
错误:函数(){}
});
});

试着用它来解析JSON

jQuery.parseJSON()
您可以像解析JSON一样 var JsonStringify_ExecResData=JSON.stringify(数据); var obj=jQuery.parseJSON(JsonStringify_ExecResData)

setItem(“userEmail”,userEmail)

您可以设置参数并进入另一个页面,如


setItem(“userEmail”,userEmail)

我不是Phonegap方面的专家,但这就是在jQuery中为特定场景创建/填充表的方法。然后,您可以将该表附加到页面上的现有元素,或者像我一样,附加到主体(因为它是一个演示)。调整此代码以满足您的需要,例如将
success:function(data){
}
之间的所有内容替换为除
var-dat=[…]之外的我的代码

var data=[{“CategoryName”:“Flash新闻”,“DisplayOrder”:“0”,“ENoticeDescription”:“ENoticeId”:19619,“NoticeDocument”:“Subject”:“歌唱比赛将于本月举行,感兴趣的候选人可以到办公室报名。”,“createddate”:“2014年6月12日”,“noticedate”:“6\/12\/2014 12:00 AM”},{“CategoryName”:“Flash新闻”,“展示顺序”:“0”,“ENoticeDescription”:“ENoticeId”:19623,“通知文件”:“主题”:“鲜花节庆祝活动将在下个月的第一个星期六进行,学生被指示携带5种不同的鲜花。”,“createddate”:“2014年6月12日”,“noticedate”:“6\/12\/2014 12:00:00 AM”,{“CategoryName”:“快讯”,“DisplayOrder”:“0”ENoticeDescription:“ENoticeId”:19624,“通知文件”:“主题”:“高级课程绘画比赛将于本月30日举行”。“创作日期”:“2014年6月12日”,“通知日期”:“6\/12\/2014 12:00:00 AM”},{“类别名称”:“快讯”,“展示订单”:“0”,“ENoticeDescription”:高年级学生辩论比赛将于4月2日举行,有兴趣的学生请联系高级课程工作人员负责人。”,“ENoticeId”:19660,“通知文件”:“主题”:“高级课程-辩论比赛”,“创建日期”:“2014年6月12日”,“通知日期”:“6\/12\/2014 12:00:00 AM”];
变量$table=$('');
var$trs=$();
$.each(数据,函数(){
var$tr=$(“”).css(“背景”,“D4D2D2”);
var$td=$(“”).css(“颜色”,“041DB3”).text(“主题:”;
$tr.append($td);
$td=$(“”).css(“颜色”,“#041DB3”).text(this.Subject);
$tr.append($td);
$trs=$trs.add($tr);
$tr=$(“”)css(“背景”,“#04A273”);
$td=$(“”).css(“颜色”和“#041DB3”).text(“说明:”);
$tr.append($td);
$td=$(“”).css(“颜色”和“#041DB3”).text(此.ENoticeDescription);
$tr.append($td);
$trs=$trs.add($tr);
});
$table.empty().append($trs);
$(“body”).empty().append($table);

请格式化你的代码。我可以写出
文档。写(“”)文档。写(“”)文档。写
,这会擦除整个文档到底是什么。不需要。OP使用的是
数据类型:'JSON'
(我知道很难读)。此外,
jQuery.parseJSON()
本身不做任何事情。这不是正确的答案。