views:

55

answers:

1

Hello,

I am having some problems with null values

Is there a good way of passing the null values from js in a way that they are interpreted the same.

This apparently is not the same

ajaxNullVar = null;
post_var = {'action': 'update_foto','fotoid': fotoid, 'ajaxNullVar': ajaxNullVar };
        $.ajax({
            url: post_url,
            data: post_var, 

in php

if ($_POST['ajaxNullVar']!=NULL)$ajaxNullVar='php null is not the same as a js null';
alert($ajaxNullVar);

I tested for a while now, and setting the null values in php, does not cause a problem when posting to the api, but coming from ajax it does?? Before I start thinking about a workaround, I thought I ask here first.

thanks, Richard

+1  A: 

if you don't pass that parameter then i think php will read it as null. i've done the following basic test:

<?php
if($_GET['a'] == null){
   echo('null');
} else{
   echo('not null');
}
?>
Josh
but if you pass them in a function, you have to give them a valueI am now passing every variable one by one to the function, hope I find the solution fast.
Richard
I think the proaublem is with the api protocol, because the code breaks on a single variable. Now I have to check if I still have the null values issue.
Richard
Still have some evaluation problems, even with var==false. So I used a 0 instead off false in ajax.
Richard