$.ajax({
    type: 'POST',
    url: url,
    success(function(data){
        //判断是否为JSON对象
        if(typeof(data) == "object" && 
            Object.prototype.toString.call(data).toLowerCase() == "[object object]" && !data.length){
            alert("is JSON 0bject");
        }
        //判断是否存在某字段
        console.info(datas["key"] != undefined); //此方式不严谨,如果key定义了 并就是赋值为undefined 则会出问题
        console.info("key" in datas);
        console.info(datas.hasOwnProperty("key"));

    })
})

 

相关文章:

  • 2021-12-07
  • 2022-12-23
  • 2021-10-16
  • 2021-11-27
  • 2021-10-19
  • 2021-12-07
猜你喜欢
  • 2022-12-23
  • 2021-11-07
  • 2021-08-11
  • 2021-06-19
  • 2022-01-21
相关资源
相似解决方案