json_encode用法
1.从数据库中查询出来的数据,放在数组中
$query=mysql_query($SQL);
while($row = mysql_fetch_array($query)){
$xdata[]=$row['EventDate'];
$ydata[]=intval($row['data']);
}
2.将数据转成json
$data_arr=array($xdata,$ydata)
json_encode($data_arr);
3.HTML 页面中 AJAX调用数据
$.ajax({
type: "Get",
url: "columndata.php?r=" + Math.floor(Math.random() * 1000 + 1),
data: { 'BeginTime': "" + beginTime + "", "EndTime": "" + endTime + "" , "keyword": "" + keyword + "" },
dataType: "text",
global: false,
async: false,
success: function (strReult) {
if (strReult == "-1") { alert("fail!"); return; }
var jsondata = eval("(" + strReult + ")");
var xData = jsondata[0];
var yData = jsondata[1];
var namestr = jsondata[2];
},
error: function () {
alert("fail!");
}
});
json_encode用法的更多相关文章
- HP数组转JSON函数json_encode和JSON转数组json_decode函数的使用方法
这两个函数比较简单,我这里直接写例子,但是有一点一定要注意,json数据只支持utf-8格式,GBK格式的数据转换为json会报错! json_encode()用法: <?php$data =a ...
- memcache基本讲解
Memcached技术 介绍: memcached是一种缓存技术, 他可以把你的数据放入内存,从而通过内存访问提速,因为内存最快的, memcached技术的主要目的提速, 在memachec 中维护 ...
- Memcached技术
Memcached技术 介绍: memcached是一种缓存技术, 他可以把你的数据放入内存,从而通过内存访问提速,因为内存最快的, memcached技术的主要目的提速, 在memachec 中维护 ...
- php中json_encode和json_decode的用法
1.json_encode基本用法:数组转字符串 <?php $arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5); ...
- php中的curl使用入门教程和常见用法实例
摘要: [目录] php中的curl使用入门教程和常见用法实例 一.curl的优势 二.curl的简单使用步骤 三.错误处理 四.获取curl请求的具体信息 五.使用curl发送post请求 六.文件 ...
- json_encode详解,转义
1.json_encod基本用法:数组转字符串 <?php $arr = array (,,,,); echo json_encode($arr); ?> 以上例程会输出: {,,,,} ...
- php中json_decode()和json_encode()的使用方法
php中json_decode()和json_encode()的使用方法 作者: 字体:[增加 减小] 类型:转载 json_decode对JSON格式的字符串进行编码而json_encode对变 ...
- php 中json_decode()和json_encode()的使用方法
1.json_decode() json_decode (PHP 5 >= 5.2.0, PECL json >= 1.2.0) json_decode — 对 JSON 格式的字符串进行 ...
- php中json_decode()和json_encode()
1.json_decode() json_decode (PHP 5 >= 5.2.0, PECL json >= 1.2.0) json_decode — 对 JSON 格式的字符串进行 ...
随机推荐
- 前端开发中Cookie那些事儿
前段时间做了项目,在前端实现中频繁的操作cookie,记录几点供大家参考! cookie操作在前端开发过程中经常遇到,当然如果只是用来存储一些简单用户数据,还是比较简单的,我们要做的可能只是设置coo ...
- gulp-uglify的使用
gulp教程之gulp-uglify 简介: 使用gulp-uglify压缩javascript文件,减小文件大小. 1.安装nodejs/全局安装gulp/项目安装gulp/创建package.js ...
- feginclinet中设置hystrix的参数
package com.example.demo; import com.netflix.hystrix.HystrixCommand; //import com.netflix.hystrix.co ...
- html+js+css+接口交互+echarts实例一枚
1. 解决了echarts的展现 2. 解决了echarts全屏幕展现(width:100%;height:100%;) 3. 解决了向接口取数据问题 <!DOCTYPE html> &l ...
- Win7网络修复,winsock/tcpip
1.win7自带网络诊断提示没有安装一个或多个协议,ip地址为169.254.x.x,dns地址为空 2.修复winsock时,提示系统找不到指定的文件. 解决办法: 1. netsh int ip ...
- sqlserver中sp_executesql使用实例(获取动态sql输出结果)
语法 sp_executesql [ @stmt = ] stmt [ {, [@params=] N'@parameter_name data_type [ [ OUT [ PUT ][,. ...
- Python的sys.argv使用说明 通过终端写入环境变量
刚开始使用这个参数的时候,很不明白其含义.网上搜索很多都是贴的官网上面的一则实例,说看懂,就明白.可是,我看不懂.现在在回头看这个参数使用,并不是很麻烦. 举几个小例子就明白了. 创建一个脚本,内容如 ...
- PowerShell中进行文件读取,信息排序,分类计数。
这是国外某大学QA的一道作业题,读取mainlog文件中的每一行信息,并获取有效的信息,也就是每条信息中第四个@后面的内容,然后进行分类与计数,要求是用Perl写,但我是用PowerShell完成的, ...
- VxWorks中logMsg与printf的区别
printf( ) - write a formatted string to the standard output stream (ANSI). logMsg( ) does not actual ...
- JS中onclick事件传参
美术馆案例中,需要将“增加一个img标签,放入大图片”这样一个函数封装,但是在调用的时候需要传参. <script type="text/javascript"> on ...