欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

ajax判断后端返回的数据是否为null的方法

程序员文章站 2022-06-24 16:22:05
1、后端返回: return null; 2、ajax需要判断: if(null != jsonstr && "" != jsonstr){...

1、后端返回:

return null;

2、ajax需要判断:

if(null != jsonstr && "" != jsonstr){

具体代码:

$.ajax(
    {
     type: "post",
     data: {
      name: name,
      code: code
     },
     datatype: "json",
     url: "info",
     success: function(jsonstr) {
      if(null != jsonstr && "" != jsonstr){
      
       $("#curator_info").html("ok");
      } else {
       $("#curator_info").html("no");
      }
     }
    }
   );

以上这篇ajax判断后端返回的数据是否为null的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

相关标签: ajax 数据 null