1

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 Answer 1

1

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');
}
?>
Sign up to request clarification or add additional context in comments.

3 Comments

but if you pass them in a function, you have to give them a value I am now passing every variable one by one to the function, hope I find the solution fast.
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.
Still have some evaluation problems, even with var==false. So I used a 0 instead off false in ajax.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.