Using the jQuery $.post
function, if you send a null
value, it arrives at the server side as "null"
. Example:
Javascript:
$.post('test.php', { foo : null });
PHP:
var_dump($_POST['foo']); // string(4) "null"
I understand why this is so, but was wondering the best way to work around the limitation? Should you:
- Loop through all the variables in JS before you send them and replace with an empty string?
- Interpret
"null"
asnull
on the server side? - Don't send the variable at all?
- Something else?