且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用jquery在HTML页面中显示json数据?

更新时间:2022-06-03 04:12:33

(文档)。 ready(function(){

debugger;
(document).ready(function () {
debugger;


.ajax({

url:'http://本地主机:25012 / NewsRestService.svc / WrappedNe wsById / 4',

数据:{},

contentType:application / json; charset = utf-8,

dataType:json,

cache:false,

})。success(function(data) {

alert(数据);
.ajax({
url: 'http://localhost:25012/NewsRestService.svc/WrappedNewsById/4',
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
cache: false,
}).success(function (data) {
alert(data);


('#data')。append(JSON.stringify(data));

});

})

< / script>



另一种代码:



< script type =text / javascript>

调试器;

var service = 'http:// localhost:25012 / NewsRestService.svc / NewsById /';
('#data').append(JSON.stringify(data));
});
})
</script>

Another Type of Code:

<script type="text/javascript">
debugger;
var service = 'http://localhost:25012/NewsRestService.svc/NewsById/';