In your JS code (removed the extra space):
if(x!=null && x!=" ") should be if(x!=null && x!="")
and
if(x==null || del==false || x==" ") should be if(x==null || del==false || x=="")
It seems alright, but i'm confused why you couldn't get the variable in your PHP script. Try to print/check $_REQUEST (which is a HTTP Request variable) or $_REQUEST["var"]. It should work.