I'm trying to send a request that origins from an object that contains null
values:
ajax_post("path", {name: "Name", status: null}, callback);
I have my own method that URL encodes the objects. null
is a javascript type object
, so it ends up here:
for(var i in data) {
...
if(typeof data[i]=="object") {
if(data[i]==null) {
//HOW TO ENCODE THE NULL VALUE?
}
else
...
}
else
...
}
The resulting $_POST
on server side should contain these:
array(
name => "Name",
status => NULL
)
Is this possible or will I have to convert "NULL"
into NULL
manually on server side?
null
when passsed on the query string? so that when the PHP receives it, the data type is stillnull
? – Tectonicnull
is in URL specification or if I'll have to create my own protocol/syntax for it. – Ferne$_POST
vars, the first thing you usually do is usingisset()
. I'd leave outnull
values and assume!isset == null
. Like:if (!isset($_POST['status'])) { $status = null; }
– Dervishnull
field to actually set something to null. So it would be most straightforward to keep the value. Also, I use the key to detect what request I'm handling. Otherwise, you're right. – FerneNULL
– Psalmsnull
,name=Name&status=
you'll just get an empty string when it transports and becomes a query string – Tectonic