$.ajax,将参数dataType的值设为json的作用

var response = await $.ajax({type: 'POST',url: url,data: null,contentType: "application/json;charset=UTF-8",dataType: "json"})

  如果后台返回的数据是JSON字符串

设置了dataType: "json"后,返回的response会自动转为JS对象。
如果不设置则是返回的是后台的JSON字符串
posted @ 2023-08-09 08:19  信铁寒胜  阅读(132)  评论(0编辑  收藏  举报