开发者

Using Ajax GET returns zero when nothing is SELECTed from sql how can I have it return nothing in this case?

Google Chrome doesn't seem to have this problem, I noticed this in Firefox.

So we start by using GET:

function execute_check(){
    $.ajax({
开发者_如何学JAVA        type:'GET',
        url: 'ajax.php',
        success: function(data){
            $("#div").html(data);
        }
    });
}

This works fine if there is something being returned.

Then we have the PHP/mysql:

$result = mysql_query("SELECT * FROM table WHERE value='1' ORDER BY time ASC");

How can I have it return NOTHING rather than 0? I also saw the same thing when I was using the require() function.


on the php side, just add a check...

if ($resultCount==0) die(null);

or if you're using require() you'll want to use...

if ($resultCount==0) $resultCount=null;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜