在AJAX响应中查找空值或空值

时间:2011-03-16 14:29:59

标签: jquery ajax

{"prepaymentList":[{"years":1,"bps":null,"targetRate":0.0236187,"TotalValueString":"","ShockString":"","KeyRate":""},{"years":2,"bps":null,"targetRate":0.0236187,"TotalValueString":"","ShockString":"","KeyRate":""},{"years":3,"bps":null,"targetRate":0.0236187,"TotalValueString":"","ShockString":"","KeyRate":""},{"years":4,"bps":null,"targetRate":0.0236187,"TotalValueString":"","ShockString":"","KeyRate":""},{"years":1,"bps":null,"targetRate":0.0186187,"TotalValueString":"","ShockString":"","KeyRate":""},{"years":2,"bps":null,"targetRate":0.0186187,"TotalValueString":"","ShockString":"","KeyRate":""},{"years":3,"bps":null,"targetRate":0.0186187,"TotalValueString":"","ShockString":"","KeyRate":""},{"years":4,"bps":null,"targetRate":0.0186187,"TotalValueString":"","ShockString":"","KeyRate":""}],"keyRateList":[{"years":1,"bps":null,"targetRate":null,"TotalValueString":"","ShockString":"","KeyRate":"2.51506"},{"years":2,"bps":null,"targetRate":null,"TotalValueString":"","ShockString":"","KeyRate":"3.03467"},{"years":3,"bps":null,"targetRate":null,"TotalValueString":"","ShockString":"","KeyRate":"3.48070"},{"years":4,"bps":null,"targetRate":null,"TotalValueString":"","ShockString":"","KeyRate":"3.87485"}],"stillRunning":true,"prepaymentLength":5}

这是我从JQuery ajax调用回来的AJAX响应。我如何通过这个来看看我是否还有使用JQuery的空或空的东西?

1 个答案:

答案 0 :(得分:0)

$.each(prepaymentList, function(index, value) {
    if (value == null || value == ' ') {
        alert(index+" is null!");
    }
}

未测试。