How to check if ajax return exist?

This question already has an answer here:

  • JavaScript check if variable exists (is defined/initialized) 28 answers
  • Checking if a key exists in a JavaScript object? 16 answers

  • You can try the following:

    $.ajax({
        url: 'DBConnector.php',
        type: 'GET',
        dataType: 'json',
        success: function(data)
        {
            if(data.status !== undefined)
            {
                //YOUR CODE HERE
            }
        }
    });
    

    It will check if the status exists or not.

    链接地址: http://www.djcxy.com/p/26632.html

    上一篇: 检查javascript对象中的键

    下一篇: 如何检查ajax是否存在?