如何使用jquery处理json数据
如摘要所说,json是常用的前后端交互的数据格式,本文简单介绍jquery如何解析json数据,以备忘。 如下是一个嵌套的json: [{"name":"20:00-21:15","price":"1.00"},{"name":"17:30-17:59","price":"1.00"}, {"name":"22:00-22:30","price":"3.00"},{"name":"20:00-21:15&22:00-22:30","price":"0.00"}] 1. 在jQuery中有一个简单的方法 $.getJSON() 可以实现. 下面引用的是官方API对$.getJSON()的说明: jQuery.getJSON( url, [data,] [success(data, textStatus, jqXHR)] ) url A string containing the URL to which the request is sent. data A map or string that is sent to the server with the request. success(data, textStatus, jqXHR) A callback function that is executed if the request succeeds. 回调函数中接受三个参数