jQuery使用ajax传json数据

不说没用的,直接上代码

这是有问题的代码:

    $.ajax({
        type: "GET",
        url: "http://www.huodongshu.com/addticket.do",
        data: "info =" + info,
        dataType: "info={"name":"11","type":"1","fee_rate":"10","fee_type":"1","start_time":"111111","end_time":"22222222","limit_min":"1","limit_max":"3","if_hide_ticket":"1","need_approve":"1","description":"aaaaaaaaaaa","if_hide_desc":"1"}",
        success: function(msg){
        }
    });

这是之后正确的代码:

var info='{"name":"11","type":"1","fee_rate":"10","fee_type":"1","start_time":"111111","end_time":"22222222","limit_min":"1","limit_max":"3","if_hide_ticket":"1","need_approve":"1","description":"aaaaaaaaaaa","if_hide_desc":"1"}';
		
    $.ajax({
	type: "GET",
	url: "http://www.huodongshu.com/addticket.do",
	data: "info=" + info,
        dataType: 'json',
	success: function(msg){
        }
    });

错误其实很小,就是单双引号的问题。

你可能感兴趣的:(jQuery使用ajax传json数据)