views:

50

answers:

1
$("#post").live("click",function()
{
    $("input:checkbox[name='bookmarkid']:checked").each(function()
    {
         $.post("php/socialbookmark-post.php", {bookmarkID: $(this).val()},function(data)
         {
              if(data != "") alert(data);
         });
    });
});

the php file outputs some text only if something goes wrong. The checking that I do fails if the data is empty and displays an empty message. I need to fix this. Any ideas?

+1  A: 

You could instead check if data exists, like this:

if(data && data !="") alert(data);

data will be null in your case, and null != "", so the if is passing.

Nick Craver
still having the same problem. must be some other way of checking....or could you post how to check if a specific string is in the return data? That would solve things instead of checking whether it's empty or not.
@user253530 - If you do `alert(data.length);` what do you get?
Nick Craver