ajax请求字符串拼接json,发送到后台@RequestBody接收

 这种方法可以将变量拼接成json格式的字符串

 
    var hashcode = '{"hashcode":\"' + row.hashcode + '\"}';//字符串拼接成Json,row.hashcode为变量
    $.ajax({
        type: 'put',
        url: '/file/queryNameByHash?_' + $.now(),
        data: hashcode,
        dataType: 'json',
        contentType: 'application/json;charset=UTF-8',//以json格式传输
    });

 用谷歌浏览器查看ajax发送的请求参数

谷歌浏览器可以对json格式进行解析

猜你喜欢

转载自blog.csdn.net/u013675978/article/details/81437290
今日推荐