在jquery中获取JSON响应状态消息

时间:2016-06-15 05:01:51

标签: jquery json spring-mvc

这是我的jquery代码...... 当我点击api时,它以json格式返回响应

我在控制台上收到此回复

Object {status_code: "fail", status_message: "Something get wrong we will reach u soon."}

我想在响应中获取状态代码=失败并在jquery中执行某些操作,例如显示警报,所以我写了这个

<script type="text/javascript">
$(document).ready(function(){ 
$("#resend").click(function() {
var mobileNumber = $("#mobileNumber").val();
    var emailId = $("#emailId").val();
     var dataresendotp = 'email='+ emailId + '&mobile=' + mobileNumber;    
     console.log(dataresendotp); 
   if(mobileNumber=='' )
    {
alert("nothing in it");
    }
    else
    {
    $.ajax({
        type: 'GET',
         url : '/geniedoc/api/user/otp?',
         data: dataresendotp,
   success: function(response){
        console.log(response);
        if ( response === false )
        {
            alert("something went wrong");

        }
  }
});}
    return false;
    });

});

但它没有用,有人可以建议如何从json中获取json的响应吗?

0 个答案:

没有答案
相关问题